save steps and point info to db
This commit is contained in:
@@ -144,11 +144,25 @@ class MineSeeker extends React.Component {
|
|||||||
if (activePlayer === this.refs.gridControl.state.webPlayer) {
|
if (activePlayer === this.refs.gridControl.state.webPlayer) {
|
||||||
this.refs.gridControl.stepEvent(coords);
|
this.refs.gridControl.stepEvent(coords);
|
||||||
|
|
||||||
|
var mineCache = this.refs.gridControl.state.foundUserMineCache,
|
||||||
|
redPoints = this.refs.gridControl.refs.userControl.refs.red.state.mines + (
|
||||||
|
this.refs.gridControl.refs.userControl.refs.red.state.active
|
||||||
|
? mineCache
|
||||||
|
: 0
|
||||||
|
),
|
||||||
|
bluePoints = this.refs.gridControl.refs.userControl.refs.blue.state.mines + (
|
||||||
|
this.refs.gridControl.refs.userControl.refs.blue.state.active
|
||||||
|
? mineCache
|
||||||
|
: 0
|
||||||
|
);
|
||||||
|
|
||||||
this.state.session
|
this.state.session
|
||||||
.publish(this.state.channel, {
|
.publish(this.state.channel, {
|
||||||
'coords': coords,
|
'coords': coords,
|
||||||
'player': activePlayer,
|
'player': activePlayer,
|
||||||
'bomb': this.refs.gridControl.refs.userControl.state.bombSelected
|
'bomb': this.refs.gridControl.refs.userControl.state.bombSelected,
|
||||||
|
'redPoints': redPoints,
|
||||||
|
'bluePoints': bluePoints
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class MineseekerTopic implements TopicInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Like RPC is will use to prefix the channel
|
* Like RPC is will use to prefix the channel
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
@@ -123,6 +124,8 @@ class MineseekerTopic implements TopicInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Save steps and point information to database
|
||||||
|
*
|
||||||
* @param $topic
|
* @param $topic
|
||||||
* @param $event
|
* @param $event
|
||||||
*/
|
*/
|
||||||
@@ -140,12 +143,18 @@ class MineseekerTopic implements TopicInterface
|
|||||||
$step->setCol($event['coords'][1]);
|
$step->setCol($event['coords'][1]);
|
||||||
$step->setWBomb($event['bomb']);
|
$step->setWBomb($event['bomb']);
|
||||||
$step->setPlayedGame($playedGame);
|
$step->setPlayedGame($playedGame);
|
||||||
|
|
||||||
$this->em->persist($step);
|
$this->em->persist($step);
|
||||||
|
|
||||||
|
$playedGame->setBluePoints($event['bluePoints']);
|
||||||
|
$playedGame->setRedPoints($event['redPoints']);
|
||||||
|
$this->em->persist($playedGame);
|
||||||
|
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Save user data to database
|
||||||
|
*
|
||||||
* @param $topic
|
* @param $topic
|
||||||
* @param $userName
|
* @param $userName
|
||||||
* @param $user
|
* @param $user
|
||||||
|
|||||||
Reference in New Issue
Block a user