Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: シークレットダイスを実装 #8

Merged
merged 1 commit into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/app/class/chat-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class ChatMessage extends ObjectNode implements ChatMessageContext, Inner
get isDirect(): boolean { return 0 < this.sendTo.length ? true : false; }
get isMine(): boolean { return (-1 < this.sendTo.indexOf(Network.peerContext.id)) || this.from === Network.peerContext.id ? true : false; }
get isDisplayable(): boolean { return this.isDirect ? this.isMine : true; }
get isSystem(): boolean { return this.tag === 'system' ? true : false; }
get isDicebot(): boolean { return this.isSystem && this.from === 'System-BCDice' ? true : false; }

innerXml(): string {
return this.isDirect ? '' : super.innerXml();
Expand All @@ -60,4 +62,4 @@ export class ChatMessage extends ObjectNode implements ChatMessageContext, Inner
parseInnerXml(element: Element) {
return super.parseInnerXml(element);
};
}
}
22 changes: 19 additions & 3 deletions src/app/class/dice-bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,29 @@ export class DiceBot extends GameObject {
identifier: '',
tabIdentifier: chatMessage.tabIdentifier,
from: 'System-BCDice',
timestamp: chatMessage.timestamp + 1,
timestamp: chatMessage.timestamp + 2,
imageIdentifier: '',
tag: 'system',
name: isSecret ? '<BCDice:シークレットダイス(未実装)>' : '<BCDice>',
name: isSecret ? '<BCDice:シークレットダイス>' : '<BCDice:' + chatMessage.name + '>',
text: result
};

let diceBotMessageSecretBroadcast: ChatMessageContext = {
identifier: '',
tabIdentifier: chatMessage.tabIdentifier,
from: 'System-BCDice',
timestamp: chatMessage.timestamp + 1,
imageIdentifier: '',
tag: 'system',
name: '<BCDice:' + chatMessage.name + '>',
text: '(シークレットダイス)'
};

if( isSecret ){
EventSystem.call('BROADCAST_MESSAGE', diceBotMessageSecretBroadcast);
chatMessage.to = chatMessage.from;
}

if (chatMessage.to != null && 0 < chatMessage.to.length) {
diceBotMessage.to = chatMessage.to;
if (chatMessage.to.indexOf(chatMessage.from) < 0) {
Expand Down Expand Up @@ -493,4 +509,4 @@ interface DiceBotStackContainer {
operater: string;
calculationResult: number;
diplayResult: string;
}
}
10 changes: 9 additions & 1 deletion src/app/component/chat-message/chat-message.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@
}
.message .tip {
font-size: 8px;
}
}

.dicebot-message .msg-text {
color:#22F;
}

.direct-message.dicebot-message .msg-text {
color:#CCF;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

色指定についてですが、パネル背景色との統一感が気になったので後で変更しようと考えています。

12 changes: 6 additions & 6 deletions src/app/component/chat-message/chat-message.component.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<div class="container">
<div class="message" [ngClass]="{'direct-message': chatMessage.isDirect}" [@flyInOut]="'in'">
<div class="message" [ngClass]="{'direct-message': chatMessage.isDirect, 'system-message':chatMessage.isSystem, 'dicebot-message': chatMessage.isDicebot}" [@flyInOut]="'in'">
<div class="image">
<img *ngIf="0 < imageFile?.url?.length" [src]="imageFile?.url | safe: 'resourceUrl'" />
</div>
<div class="body">
<div class="title">
<span style="font-weight: bold;">{{chatMessage.name}}</span>
<span class='tip'> From: {{chatMessage.from}}</span>
<span class='tip'> {{chatMessage.timestamp | date:'y/M/d H:mm'}}</span>
<span class="msg-name" style="font-weight: bold;">{{chatMessage.name}}</span>
<span class='tip msg-from'> From: {{chatMessage.from}}</span>
<span class='tip msg-timestamp'> {{chatMessage.timestamp | date:'y/M/d H:mm'}}</span>
</div>
<div class="text"><span>{{chatMessage.text}}</span></div>
<div class="text msg-text"><span>{{chatMessage.text}}</span></div>
</div>
</div>
</div>
</div>