Commit 645b87c2 authored by 18손재민's avatar 18손재민 Committed by 18신대성

반격에 성공 시 그 단어를 공격자에게 되돌림

parent ba5266f5
...@@ -115,7 +115,7 @@ socket.on('attacked', function(msg) // object attackData ...@@ -115,7 +115,7 @@ socket.on('attacked', function(msg) // object attackData
//console.log('attacked by ' + msg.attacker.nickname); //console.log('attacked by ' + msg.attacker.nickname);
setTimeout(function() setTimeout(function()
{ {
WordSpace.generateWord.Attack(ScenesData.gameScene, msg.text, msg.grade, msg.attacker, msg.isStrong); WordSpace.generateWord.Attack(ScenesData.gameScene, msg.text, msg.grade, msg.attacker, msg.isStrong, msg.isCountable);
}, 4000); }, 4000);
}); });
socket.on('defeat', function(msg) // object player socket.on('defeat', function(msg) // object player
......
...@@ -138,15 +138,16 @@ class NormalWord extends WordObject ...@@ -138,15 +138,16 @@ class NormalWord extends WordObject
class AttackWord extends WordObject class AttackWord extends WordObject
{ {
constructor(text, _wordGrade, _playerData, isStrong) constructor(text, _wordGrade, _playerData, _isStrong, _isCountable = true, lenRate)
{ {
super(text); super(text);
this.wordGrade = _wordGrade; this.wordGrade = _wordGrade;
this.wordWeight = this.isStrong ? WordReader.strongAttackWeight[3 - this.wordGrade] : WordReader.attackWeight[3 - this.wordGrade]; this.wordWeight = _isStrong ? WordReader.strongAttackWeight[3 - this.wordGrade] : WordReader.attackWeight[3 - this.wordGrade];
if(WordReader.getWordTyping(_playerData.nickname) > 9) if(WordReader.getWordTyping(_playerData.nickname) > 9)
this.wordWeight += this.wordWeight * 0.2 * (WordReader.getWordTyping(_playerData.nickname) - 9); this.wordWeight += this.wordWeight * 0.2 * (WordReader.getWordTyping(_playerData.nickname) - 9);
this.attacker = _playerData; this.attacker = _playerData;
this.counterTime = WordSpace.gameTimer.now + 1000 * (this.wordTyping <= (5 - _wordGrade) * 2.5 ? this.wordTyping / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5 : if(!_isCountable) this.counterTime = 0;
else this.counterTime = WordSpace.gameTimer.now + 1000 * (this.wordTyping <= (5 - _wordGrade) * 2.5 ? this.wordTyping / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5 :
((5 - _wordGrade) * 3 + (this.wordTyping - (5 - _wordGrade) * 2.5) * 2.5) / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5); ((5 - _wordGrade) * 3 + (this.wordTyping - (5 - _wordGrade) * 2.5) * 2.5) / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5);
console.log('Attack text : ' + text + ', Attacker : ' + this.attacker.nickname + ', Weight : ' + this.wordWeight); console.log('Attack text : ' + text + ', Attacker : ' + this.attacker.nickname + ', Weight : ' + this.wordWeight);
console.log('Counter time : ' + this.counterTime); console.log('Counter time : ' + this.counterTime);
...@@ -197,6 +198,17 @@ class AttackWord extends WordObject ...@@ -197,6 +198,17 @@ class AttackWord extends WordObject
tempWord.physicsObj.setPosition(this.physicsObj.x, this.physicsObj.y); tempWord.physicsObj.setPosition(this.physicsObj.x, this.physicsObj.y);
tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y); tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y);
tempWord.destroy(); tempWord.destroy();
let attackData =
{
roomNum: RoomData.roomId,
attacker: RoomData.myself,
target: this.attacker.id,
text: this.wordText,
grade: Math.min(3, this.wordGrade + 1),
isStrong: false,
isCountable: false
}
socket.emit('attack', attackData);
} }
if(this.maskBackground != null) this.maskBackground.destroy(); if(this.maskBackground != null) this.maskBackground.destroy();
super.destroy(); super.destroy();
......
...@@ -287,9 +287,9 @@ WordSpace.generateWord = ...@@ -287,9 +287,9 @@ WordSpace.generateWord =
WordSpace.pushWord(scene, word, lenRate); WordSpace.pushWord(scene, word, lenRate);
return word; return word;
}, },
Attack: function(scene, wordText, grade, attacker, isStrong, lenRate) Attack: function(scene, wordText, grade, attacker, isStrong, isCountable, lenRate)
{ {
word = new AttackWord(wordText, grade, attacker, isStrong); word = new AttackWord(wordText, grade, attacker, isStrong, isCountable);
WordSpace.pushWord(scene, word, lenRate); WordSpace.pushWord(scene, word, lenRate);
return word; return word;
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment