Skip to content

Commit

Permalink
Merge pull request #8 from kumakaba/secret_dice
Browse files Browse the repository at this point in the history
fix: シークレットダイスを実装
  • Loading branch information
TK11235 authored Oct 27, 2017
2 parents 454acc1 + f2c3e60 commit 2a992de
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
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 @@ -471,4 +487,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;
}
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>

0 comments on commit 2a992de

Please sign in to comment.