self targeting client
This commit is contained in:
parent
b5191e5306
commit
09b6f455d3
@ -616,11 +616,11 @@ module.exports = {
|
||||
avoidQuotes: true,
|
||||
}],
|
||||
|
||||
// suggest using arrow functions as callbacks
|
||||
'prefer-arrow-callback': ['error', {
|
||||
allowNamedFunctions: false,
|
||||
allowUnboundThis: true,
|
||||
}],
|
||||
// // suggest using arrow functions as callbacks
|
||||
// 'prefer-arrow-callback': ['error', {
|
||||
// allowNamedFunctions: false,
|
||||
// allowUnboundThis: true,
|
||||
// }],
|
||||
|
||||
// suggest using of const declaration for variables that are never modified after declared
|
||||
'prefer-const': ['error', {
|
||||
|
||||
@ -10,11 +10,16 @@ const addState = connect(
|
||||
|
||||
function selectSkillTarget(targetTeamId) {
|
||||
if (activeSkill) {
|
||||
return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill);
|
||||
return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill.skill);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// intercept self casting skills
|
||||
if (activeSkill && activeSkill.skill.self_targeting) {
|
||||
ws.sendGameSkill(game.id, activeSkill.crypId, null, activeSkill.skill.skill);
|
||||
}
|
||||
|
||||
function selectIncomingTarget(crypId) {
|
||||
if (activeIncoming) {
|
||||
return ws.sendGameTarget(game.id, crypId, activeIncoming);
|
||||
@ -27,11 +32,11 @@ const addState = connect(
|
||||
|
||||
function receiveDispatch(dispatch) {
|
||||
function setActiveSkill(crypId, skill) {
|
||||
dispatch(actions.setActiveSkill(crypId, skill))
|
||||
dispatch(actions.setActiveSkill(crypId, skill));
|
||||
}
|
||||
|
||||
function setActiveIncoming(skillId) {
|
||||
dispatch(actions.setActiveIncoming(skillId))
|
||||
dispatch(actions.setActiveIncoming(skillId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ function GamePanel(props) {
|
||||
|
||||
const playerTeam = game.teams.find(t => t.id === account.id);
|
||||
|
||||
const incoming = game.skills.filter(s => s.target_team_id === playerTeam.id).map((inc) => {
|
||||
const incoming = game.stack.filter(s => s.target_team_id === playerTeam.id).map((inc) => {
|
||||
key.unbind('1');
|
||||
key('1', () => setActiveIncoming(inc.id));
|
||||
return (
|
||||
@ -41,14 +41,14 @@ function GamePanel(props) {
|
||||
const skills = cryp.skills.map((skill, i) => {
|
||||
const hotkey = SKILL_HOT_KEYS[i];
|
||||
key.unbind(hotkey);
|
||||
key(hotkey, () => setActiveSkill(cryp.id, skill.skill));
|
||||
key(hotkey, () => setActiveSkill(cryp.id, skill));
|
||||
|
||||
return (
|
||||
<button
|
||||
key={i}
|
||||
className="button is-dark"
|
||||
type="submit"
|
||||
onClick={() => setActiveSkill(cryp.id, skill.skill)}
|
||||
onClick={() => setActiveSkill(cryp.id, skill)}
|
||||
>
|
||||
({hotkey}) {skill.skill} {skill.cd && `(${skill.cd}T)`}
|
||||
</button>
|
||||
@ -59,7 +59,6 @@ function GamePanel(props) {
|
||||
<div key={i}>{status} for {status.turns}T</div>
|
||||
));
|
||||
|
||||
if (activeIncoming) console.log('should be a pointer');
|
||||
return (
|
||||
<div
|
||||
key={cryp.id}
|
||||
|
||||
@ -288,6 +288,7 @@ pub fn cryp_spawn(params: CrypSpawnParams, tx: &mut Transaction, account: &Accou
|
||||
.named(¶ms.name)
|
||||
.level(10)
|
||||
.learn(Skill::Stun)
|
||||
.learn(Skill::Block)
|
||||
.set_account(account.id)
|
||||
.create();
|
||||
|
||||
|
||||
@ -273,6 +273,10 @@ impl Game {
|
||||
|
||||
// targets can only be added by the owner of the team
|
||||
fn add_target(&mut self, team_id: Uuid, cryp_id: Uuid, skill_id: Uuid) -> Result<&mut Cast, Error> {
|
||||
if self.phase != Phase::Target {
|
||||
return Err(err_msg("game not in target phase"));
|
||||
}
|
||||
|
||||
{
|
||||
// whose team is this?
|
||||
let team = self.team_by_id(team_id);
|
||||
@ -414,6 +418,10 @@ pub fn game_skill(params: GameSkillParams, tx: &mut Transaction, account: &Accou
|
||||
let game_bytes: Vec<u8> = returned.get("data");
|
||||
let mut game = from_slice::<Game>(&game_bytes)?;
|
||||
|
||||
if game.phase != Phase::Skill {
|
||||
return Err(err_msg("game not in skill phase"))
|
||||
}
|
||||
|
||||
game.add_skill(account.id, params.cryp_id, params.target_team_id, params.skill)?;
|
||||
|
||||
if game.skill_phase_finished() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user