fix game construct css classes

This commit is contained in:
Mashy 2019-12-09 11:18:52 +10:00
parent 60587351b5
commit d33cda012e
5 changed files with 32 additions and 24 deletions

View File

@ -40,8 +40,11 @@ class GameConstruct extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.activeSkill !== this.props.activeSkill) 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.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;
}
@ -56,15 +59,17 @@ class GameConstruct extends preact.Component {
player,
} = this.props;
const koEvent = resolution && resolution.text === 'KO!' && resolution.constructId === construct.id;
const ko = construct.green_life.value === 0 && !koEvent ? 'ko' : '';
const cssClass = () => {
if (koEvent) return 'ko-transition';
if (animFocus && !animFocus.includes(construct.id)) return 'unfocus';
const ko = construct.green_life.value === 0 ? 'ko' : '';
const koEvent = () => {
if (resolution) {
const [type, variant] = resolution.event;
if (variant.construct === construct.id && type === 'Ko') return 'ko-transition';
}
return '';
};
const unfocus = animFocus && !animFocus.includes(construct.id) ? 'unfocus' : '';
const crypSkills = player
? <div class="skills"> {range(0, 3).map(j => <SkillBtn key={j} construct={construct} i={j} />)} </div>
: <div></div>;
@ -74,7 +79,7 @@ class GameConstruct extends preact.Component {
<div
onClick={() => selectSkillTarget(construct.id)}
style={ activeSkill ? { cursor: 'pointer' } : {}}
class={`game-construct ${ko} ${cssClass()}`}>
class={`game-construct ${ko} ${koEvent()} ${unfocus}`}>
<div class="left">
{crypSkills}
<ConstructEffectBox construct={construct} />

View File

@ -8,8 +8,8 @@ const addState = connect(({ resolution }) => ({ resolution }));
class GameConstructLife extends preact.Component {
shouldComponentUpdate(newProps) {
if (newProps.resolution && newProps.resolution !== this.props.resolution) {
const [type, info] = newProps.resolution.event;
if (info.construct === this.props.construct.id
const [type, variant] = newProps.resolution.event;
if (variant.construct === this.props.construct.id
&& (type === 'Damage' || type === 'Healing' || type === 'Recharge')) return true;
}
if (newProps.construct !== this.props.construct) return true;

View File

@ -240,7 +240,10 @@ function convertItem(v) {
}
function effectInfo(i) {
const hybridBlast = 25;
// FIX ME
return 'effect info to be fixed';
/*const hybridBlast = 25;
const hasteStrike = 30;
function multiplier(s) { // Update later to use server info in future
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.`;
default: return 'Missing Effect Text';
}
}*/
}
module.exports = {

View File

@ -533,8 +533,8 @@ impl Game {
for action in cast.actions() {
let events = match action {
Action::Cast { construct } => self.cast(construct, cast),
Action::Hit { construct } => self.hit(construct, cast),
Action::Cast => self.cast(cast),
Action::Hit => self.hit(cast),
Action::Damage { construct, values, colour } => {
let amount = self.calculate_amount(&values, &resolved);
@ -663,12 +663,12 @@ impl Game {
// }
}
fn cast(&mut self, construct: Uuid, cast: Cast) -> Vec<Event> {
vec![Event::Cast { construct, player: cast.player, direction: self.direction(cast) }]
fn cast(&mut self, cast: Cast) -> Vec<Event> {
vec![Event::Cast { construct: cast.source, player: cast.player, direction: self.direction(cast) }]
}
fn hit(&mut self, construct: Uuid, cast: Cast) -> Vec<Event> {
vec![Event::Hit { construct, player: cast.player, direction: self.direction(cast) }]
fn hit(&mut self, cast: Cast) -> Vec<Event> {
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> {
@ -893,8 +893,8 @@ pub enum Value {
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub enum Action {
Hit { construct: Uuid },
Cast { construct: Uuid },
Hit,
Cast,
Heal { construct: Uuid, values: Vec<Value>, colour: Colour },
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
Effect { construct: Uuid, effect: ConstructEffect },

View File

@ -57,10 +57,10 @@ impl Cast {
let mut actions = vec![];
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 {
Skill::Attack => vec![
@ -1616,12 +1616,12 @@ mod tests {
let actions = cast.actions();
match actions[0] {
Action::Cast { construct: _ } => (),
Action::Cast => (),
_ => panic!("{:?}", actions),
};
match actions[1] {
Action::Hit { construct: _ } => (),
Action::Hit => (),
_ => panic!("{:?}", actions),
};