fix game construct css classes
This commit is contained in:
parent
60587351b5
commit
d33cda012e
@ -40,8 +40,11 @@ class GameConstruct extends preact.Component {
|
|||||||
shouldComponentUpdate(newProps) {
|
shouldComponentUpdate(newProps) {
|
||||||
if (newProps.activeSkill !== this.props.activeSkill) return true;
|
if (newProps.activeSkill !== this.props.activeSkill) return true;
|
||||||
if (newProps.animFocus !== this.props.animFocus) return true;
|
if (newProps.animFocus !== this.props.animFocus) return true;
|
||||||
if (newProps.resolution !== this.props.resolution) return true;
|
|
||||||
if (newProps.construct !== this.props.construct) return true;
|
if (newProps.construct !== this.props.construct) return true;
|
||||||
|
if (newProps.resolution && newProps.resolution !== this.props.resolution) {
|
||||||
|
const [type, variant] = newProps.resolution.event;
|
||||||
|
if (variant.construct === this.props.construct.id && type === 'Ko') return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,15 +59,17 @@ class GameConstruct extends preact.Component {
|
|||||||
player,
|
player,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const koEvent = resolution && resolution.text === 'KO!' && resolution.constructId === construct.id;
|
const ko = construct.green_life.value === 0 ? 'ko' : '';
|
||||||
const ko = construct.green_life.value === 0 && !koEvent ? 'ko' : '';
|
const koEvent = () => {
|
||||||
|
if (resolution) {
|
||||||
const cssClass = () => {
|
const [type, variant] = resolution.event;
|
||||||
if (koEvent) return 'ko-transition';
|
if (variant.construct === construct.id && type === 'Ko') return 'ko-transition';
|
||||||
if (animFocus && !animFocus.includes(construct.id)) return 'unfocus';
|
}
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const unfocus = animFocus && !animFocus.includes(construct.id) ? 'unfocus' : '';
|
||||||
|
|
||||||
const crypSkills = player
|
const crypSkills = player
|
||||||
? <div class="skills"> {range(0, 3).map(j => <SkillBtn key={j} construct={construct} i={j} />)} </div>
|
? <div class="skills"> {range(0, 3).map(j => <SkillBtn key={j} construct={construct} i={j} />)} </div>
|
||||||
: <div></div>;
|
: <div></div>;
|
||||||
@ -74,7 +79,7 @@ class GameConstruct extends preact.Component {
|
|||||||
<div
|
<div
|
||||||
onClick={() => selectSkillTarget(construct.id)}
|
onClick={() => selectSkillTarget(construct.id)}
|
||||||
style={ activeSkill ? { cursor: 'pointer' } : {}}
|
style={ activeSkill ? { cursor: 'pointer' } : {}}
|
||||||
class={`game-construct ${ko} ${cssClass()}`}>
|
class={`game-construct ${ko} ${koEvent()} ${unfocus}`}>
|
||||||
<div class="left">
|
<div class="left">
|
||||||
{crypSkills}
|
{crypSkills}
|
||||||
<ConstructEffectBox construct={construct} />
|
<ConstructEffectBox construct={construct} />
|
||||||
|
|||||||
@ -8,8 +8,8 @@ const addState = connect(({ resolution }) => ({ resolution }));
|
|||||||
class GameConstructLife extends preact.Component {
|
class GameConstructLife extends preact.Component {
|
||||||
shouldComponentUpdate(newProps) {
|
shouldComponentUpdate(newProps) {
|
||||||
if (newProps.resolution && newProps.resolution !== this.props.resolution) {
|
if (newProps.resolution && newProps.resolution !== this.props.resolution) {
|
||||||
const [type, info] = newProps.resolution.event;
|
const [type, variant] = newProps.resolution.event;
|
||||||
if (info.construct === this.props.construct.id
|
if (variant.construct === this.props.construct.id
|
||||||
&& (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true;
|
&& (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true;
|
||||||
}
|
}
|
||||||
if (newProps.construct !== this.props.construct) return true;
|
if (newProps.construct !== this.props.construct) return true;
|
||||||
|
|||||||
@ -240,7 +240,10 @@ function convertItem(v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function effectInfo(i) {
|
function effectInfo(i) {
|
||||||
const hybridBlast = 25;
|
// FIX ME
|
||||||
|
return 'effect info to be fixed';
|
||||||
|
|
||||||
|
/*const hybridBlast = 25;
|
||||||
const hasteStrike = 30;
|
const hasteStrike = 30;
|
||||||
function multiplier(s) { // Update later to use server info in future
|
function multiplier(s) { // Update later to use server info in future
|
||||||
if (s === 'CounterAttack') return 120;
|
if (s === 'CounterAttack') return 120;
|
||||||
@ -295,7 +298,7 @@ function effectInfo(i) {
|
|||||||
case 'Siphon': return `Construct will take ${multiplier(i.tick.skill)}% of caster's BluePower + GreenPower as blue damage each turn, healing the caster.`;
|
case 'Siphon': return `Construct will take ${multiplier(i.tick.skill)}% of caster's BluePower + GreenPower as blue damage each turn, healing the caster.`;
|
||||||
|
|
||||||
default: return 'Missing Effect Text';
|
default: return 'Missing Effect Text';
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -533,8 +533,8 @@ impl Game {
|
|||||||
|
|
||||||
for action in cast.actions() {
|
for action in cast.actions() {
|
||||||
let events = match action {
|
let events = match action {
|
||||||
Action::Cast { construct } => self.cast(construct, cast),
|
Action::Cast => self.cast(cast),
|
||||||
Action::Hit { construct } => self.hit(construct, cast),
|
Action::Hit => self.hit(cast),
|
||||||
|
|
||||||
Action::Damage { construct, values, colour } => {
|
Action::Damage { construct, values, colour } => {
|
||||||
let amount = self.calculate_amount(&values, &resolved);
|
let amount = self.calculate_amount(&values, &resolved);
|
||||||
@ -663,12 +663,12 @@ impl Game {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cast(&mut self, construct: Uuid, cast: Cast) -> Vec<Event> {
|
fn cast(&mut self, cast: Cast) -> Vec<Event> {
|
||||||
vec![Event::Cast { construct, player: cast.player, direction: self.direction(cast) }]
|
vec![Event::Cast { construct: cast.source, player: cast.player, direction: self.direction(cast) }]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hit(&mut self, construct: Uuid, cast: Cast) -> Vec<Event> {
|
fn hit(&mut self, cast: Cast) -> Vec<Event> {
|
||||||
vec![Event::Hit { construct, player: cast.player, direction: self.direction(cast) }]
|
vec![Event::Hit { construct: cast.target, player: cast.player, direction: self.direction(cast) }]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn damage(&mut self, construct: Uuid, amount: usize, colour: Colour) -> Vec<Event> {
|
fn damage(&mut self, construct: Uuid, amount: usize, colour: Colour) -> Vec<Event> {
|
||||||
@ -893,8 +893,8 @@ pub enum Value {
|
|||||||
|
|
||||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
Hit { construct: Uuid },
|
Hit,
|
||||||
Cast { construct: Uuid },
|
Cast,
|
||||||
Heal { construct: Uuid, values: Vec<Value>, colour: Colour },
|
Heal { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||||
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||||
Effect { construct: Uuid, effect: ConstructEffect },
|
Effect { construct: Uuid, effect: ConstructEffect },
|
||||||
|
|||||||
@ -57,10 +57,10 @@ impl Cast {
|
|||||||
let mut actions = vec![];
|
let mut actions = vec![];
|
||||||
|
|
||||||
if self.skill.cast_animation() {
|
if self.skill.cast_animation() {
|
||||||
actions.push(Action::Cast { construct: self.source });
|
actions.push(Action::Cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.push(Action::Hit { construct: self.target });
|
actions.push(Action::Hit);
|
||||||
|
|
||||||
let mut rest = match self.skill {
|
let mut rest = match self.skill {
|
||||||
Skill::Attack => vec![
|
Skill::Attack => vec![
|
||||||
@ -1616,12 +1616,12 @@ mod tests {
|
|||||||
let actions = cast.actions();
|
let actions = cast.actions();
|
||||||
|
|
||||||
match actions[0] {
|
match actions[0] {
|
||||||
Action::Cast { construct: _ } => (),
|
Action::Cast => (),
|
||||||
_ => panic!("{:?}", actions),
|
_ => panic!("{:?}", actions),
|
||||||
};
|
};
|
||||||
|
|
||||||
match actions[1] {
|
match actions[1] {
|
||||||
Action::Hit { construct: _ } => (),
|
Action::Hit => (),
|
||||||
_ => panic!("{:?}", actions),
|
_ => panic!("{:?}", actions),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user