Merge branch 'master' of ssh://mnml.gg:40022/~/mnml
This commit is contained in:
commit
e8d9075dfd
@ -3,7 +3,7 @@ const preact = require('preact');
|
|||||||
const range = require('lodash/range');
|
const range = require('lodash/range');
|
||||||
|
|
||||||
const actions = require('../actions');
|
const actions = require('../actions');
|
||||||
const { STATS, eventClasses, getCombatText, ConstructAvatar, constructHealth } = require('../utils');
|
const { STATS, eventClasses, getCombatText, ConstructAvatar } = require('../utils');
|
||||||
const { animationDivs } = require('../animations');
|
const { animationDivs } = require('../animations');
|
||||||
const shapes = require('./shapes');
|
const shapes = require('./shapes');
|
||||||
|
|
||||||
@ -56,12 +56,11 @@ function GameConstruct(props) {
|
|||||||
const ko = construct.green_life.value === 0 ? 'ko' : '';
|
const ko = construct.green_life.value === 0 ? 'ko' : '';
|
||||||
const classes = eventClasses(resolution, construct);
|
const classes = eventClasses(resolution, construct);
|
||||||
|
|
||||||
const life = constructHealth(resolution, construct);
|
|
||||||
const stats = ['RedLife', 'GreenLife', 'BlueLife'].map((s, j) => (
|
const stats = ['RedLife', 'GreenLife', 'BlueLife'].map((s, j) => (
|
||||||
<div key={j} alt={STATS[s].stat}>
|
<div key={j} alt={STATS[s].stat}>
|
||||||
{shapes[s]()}
|
{shapes[s]()}
|
||||||
<div className="max" >{life[s]} / {construct[STATS[s].stat].max}</div>
|
<div className="max" >{construct[STATS[s].stat].value} / {construct[STATS[s].stat].max}</div>
|
||||||
<div className="value" >{life[s]}</div>
|
<div className="value" >{construct[STATS[s].stat].value}</div>
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@ -157,74 +157,6 @@ const STATS = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function constructHealth(resolution, construct) {
|
|
||||||
if (!resolution) {
|
|
||||||
return {
|
|
||||||
RedLife: construct.red_life.value,
|
|
||||||
GreenLife: construct.green_life.value,
|
|
||||||
BlueLife: construct.blue_life.value,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const [type, event] = resolution.event;
|
|
||||||
|
|
||||||
|
|
||||||
if (construct.id !== resolution.target.id) {
|
|
||||||
if (construct.id === resolution.source.id) {
|
|
||||||
return {
|
|
||||||
RedLife: resolution.source.red,
|
|
||||||
GreenLife: resolution.source.green,
|
|
||||||
BlueLife: resolution.source.blue,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
RedLife: construct.red_life.value,
|
|
||||||
GreenLife: construct.green_life.value,
|
|
||||||
BlueLife: construct.blue_life.value,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let RedLife = resolution.target.red;
|
|
||||||
let BlueLife = resolution.target.blue;
|
|
||||||
let GreenLife = resolution.target.green;
|
|
||||||
|
|
||||||
if (resolution.stage === 'POST_SKILL') {
|
|
||||||
return { RedLife, GreenLife, BlueLife };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'Damage') {
|
|
||||||
const { amount, mitigation, colour } = event;
|
|
||||||
|
|
||||||
GreenLife = construct.green_life.max < GreenLife + amount
|
|
||||||
? construct.green_life.max
|
|
||||||
: GreenLife + amount;
|
|
||||||
|
|
||||||
if (colour === 'Red') {
|
|
||||||
RedLife = construct.red_life.max < RedLife + mitigation
|
|
||||||
? construct.red_life.max
|
|
||||||
: RedLife + mitigation;
|
|
||||||
}
|
|
||||||
if (colour === 'Blue') {
|
|
||||||
BlueLife = construct.blue_life.max < BlueLife + mitigation
|
|
||||||
? construct.blue_life.max
|
|
||||||
: BlueLife + mitigation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'Healing') {
|
|
||||||
const { amount } = event;
|
|
||||||
GreenLife = GreenLife - amount < 0 ? 0 : GreenLife - amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'Recharge') {
|
|
||||||
const { red, blue } = event;
|
|
||||||
RedLife = RedLife - red < 0 ? 0 : RedLife - red;
|
|
||||||
BlueLife = BlueLife - red < 0 ? 0 : BlueLife - blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return { RedLife, GreenLife, BlueLife };
|
|
||||||
}
|
|
||||||
|
|
||||||
function eventClasses(resolution, construct) {
|
function eventClasses(resolution, construct) {
|
||||||
if (!resolution) return '';
|
if (!resolution) return '';
|
||||||
const startSkill = resolution.stage === 'START_SKILL';
|
const startSkill = resolution.stage === 'START_SKILL';
|
||||||
@ -264,15 +196,16 @@ function eventClasses(resolution, construct) {
|
|||||||
|
|
||||||
// Deal damage to construct and return effect
|
// Deal damage to construct and return effect
|
||||||
if (target && postSkill) {
|
if (target && postSkill) {
|
||||||
|
construct.green_life.value = resolution.target.green;
|
||||||
if (colour === 'Red') {
|
if (colour === 'Red') {
|
||||||
|
construct.red_life.value = resolution.target.red;
|
||||||
return 'red-damage';
|
return 'red-damage';
|
||||||
}
|
}
|
||||||
if (colour === 'Blue') {
|
if (colour === 'Blue') {
|
||||||
|
construct.blue_life.value = resolution.target.blue;
|
||||||
return 'blue-damage';
|
return 'blue-damage';
|
||||||
}
|
}
|
||||||
if (colour === 'Green') return 'green-damage';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'Healing') {
|
if (type === 'Healing') {
|
||||||
@ -280,7 +213,9 @@ function eventClasses(resolution, construct) {
|
|||||||
if (source && startSkill) return 'active-skill';
|
if (source && startSkill) return 'active-skill';
|
||||||
if (target && endSkill) return 'active-skill';
|
if (target && endSkill) return 'active-skill';
|
||||||
if (target && postSkill) {
|
if (target && postSkill) {
|
||||||
|
construct.green_life.value = resolution.target.green;
|
||||||
return 'green-damage';
|
return 'green-damage';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,9 +228,10 @@ function eventClasses(resolution, construct) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'Effect') {
|
if (type === 'Effect') {
|
||||||
const { skill, effect, duration } = event;
|
const { skill, effect, duration, construct_effects: constructEffects } = event;
|
||||||
if (source && startSkill) return 'active-skill';
|
if (source && startSkill) return 'active-skill';
|
||||||
if (target && endSkill) return 'active-skill';
|
if (target && endSkill) return 'active-skill';
|
||||||
|
if (target && postSkill) construct.effects = constructEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'Skill') {
|
if (type === 'Skill') {
|
||||||
@ -306,7 +242,10 @@ function eventClasses(resolution, construct) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'Removal') {
|
if (type === 'Removal') {
|
||||||
const { effect } = event;
|
const { effect, construct_effects: constructEffects } = event;
|
||||||
|
if (source && startSkill) return 'active-skill';
|
||||||
|
if (target && endSkill) return 'active-skill';
|
||||||
|
if (target && postSkill) construct.effects = constructEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'Recharge') {
|
if (type === 'Recharge') {
|
||||||
@ -314,9 +253,19 @@ function eventClasses(resolution, construct) {
|
|||||||
if (source && startSkill) return 'active-skill';
|
if (source && startSkill) return 'active-skill';
|
||||||
if (target && endSkill) return 'active-skill';
|
if (target && endSkill) return 'active-skill';
|
||||||
if (target && postSkill) {
|
if (target && postSkill) {
|
||||||
if (red > 0 && blue > 0) return 'purple-damage';
|
if (red > 0 && blue > 0) {
|
||||||
if (red > 0) return 'red-damage';
|
construct.red_life.value = resolution.target.red;
|
||||||
if (blue > 0) return 'blue-damage';
|
construct.blue_life.value = resolution.target.blue;
|
||||||
|
return 'purple-damage';
|
||||||
|
}
|
||||||
|
if (red > 0) {
|
||||||
|
construct.red_life.value = resolution.target.red;
|
||||||
|
return 'red-damage';
|
||||||
|
}
|
||||||
|
if (blue > 0) {
|
||||||
|
construct.blue_life.value = resolution.target.blue;
|
||||||
|
return 'blue-damage';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +437,6 @@ module.exports = {
|
|||||||
eventClasses,
|
eventClasses,
|
||||||
getCombatSequence,
|
getCombatSequence,
|
||||||
getCombatText,
|
getCombatText,
|
||||||
constructHealth,
|
|
||||||
NULL_UUID,
|
NULL_UUID,
|
||||||
STATS,
|
STATS,
|
||||||
COLOURS,
|
COLOURS,
|
||||||
|
|||||||
@ -757,13 +757,6 @@ impl Construct {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo modified durations cause of buffs
|
|
||||||
let result = Event::Effect {
|
|
||||||
effect: effect.effect,
|
|
||||||
duration: effect.duration,
|
|
||||||
skill,
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(p) = self.effects.iter().position(|ce| ce.effect == effect.effect) {
|
if let Some(p) = self.effects.iter().position(|ce| ce.effect == effect.effect) {
|
||||||
// duplicate effect
|
// duplicate effect
|
||||||
// replace existing
|
// replace existing
|
||||||
@ -775,6 +768,13 @@ impl Construct {
|
|||||||
self.effects.push(effect);
|
self.effects.push(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo modified durations cause of buffs
|
||||||
|
let result = Event::Effect {
|
||||||
|
effect: effect.effect,
|
||||||
|
duration: effect.duration,
|
||||||
|
construct_effects: self.effects.clone(),
|
||||||
|
skill,
|
||||||
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -528,7 +528,7 @@ impl Game {
|
|||||||
self.log.push(format!("[{:}] {:} {:?} {:} REFLECTED",
|
self.log.push(format!("[{:}] {:} {:?} {:} REFLECTED",
|
||||||
speed, source.name, skill, target.name)),
|
speed, source.name, skill, target.name)),
|
||||||
|
|
||||||
Event::Effect { skill, effect, duration } =>
|
Event::Effect { skill, effect, duration, construct_effects: _ } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
|
self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
|
||||||
speed, source.name, skill, target.name, effect, duration)),
|
speed, source.name, skill, target.name, effect, duration)),
|
||||||
|
|
||||||
@ -540,7 +540,7 @@ impl Game {
|
|||||||
self.log.push(format!("[{:}] {:} {:?} {:}",
|
self.log.push(format!("[{:}] {:} {:?} {:}",
|
||||||
speed, source.name, skill, target.name)),
|
speed, source.name, skill, target.name)),
|
||||||
|
|
||||||
Event::Removal { effect } =>
|
Event::Removal { effect, construct_effects: _ } =>
|
||||||
self.log.push(format!("[{:}] {:?} removed {:} {:?}",
|
self.log.push(format!("[{:}] {:?} removed {:} {:?}",
|
||||||
speed, source.name, target.name, effect)),
|
speed, source.name, target.name, effect)),
|
||||||
|
|
||||||
@ -1265,7 +1265,7 @@ mod tests {
|
|||||||
|
|
||||||
let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap();
|
let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap();
|
||||||
match event {
|
match event {
|
||||||
Event::Effect { effect, skill: _, duration: _ } => assert_eq!(effect, Effect::Scatter),
|
Event::Effect { effect, skill: _, duration: _, construct_effects: _ } => assert_eq!(effect, Effect::Scatter),
|
||||||
_ => panic!("not siphon"),
|
_ => panic!("not siphon"),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1357,7 +1357,7 @@ mod tests {
|
|||||||
let Resolution { source, target: _, event } = r;
|
let Resolution { source, target: _, event } = r;
|
||||||
match source.id == x_construct.id {
|
match source.id == x_construct.id {
|
||||||
true => match event {
|
true => match event {
|
||||||
Event::Effect { effect, duration, skill: _ } => {
|
Event::Effect { effect, duration, skill: _, construct_effects: _ } => {
|
||||||
assert!(*effect == Effect::Stun);
|
assert!(*effect == Effect::Stun);
|
||||||
assert!(*duration == 1);
|
assert!(*duration == 1);
|
||||||
true
|
true
|
||||||
|
|||||||
@ -437,10 +437,10 @@ pub enum Event {
|
|||||||
Recharge { skill: Skill, red: u64, blue: u64 },
|
Recharge { skill: Skill, red: u64, blue: u64 },
|
||||||
Inversion { skill: Skill },
|
Inversion { skill: Skill },
|
||||||
Reflection { skill: Skill },
|
Reflection { skill: Skill },
|
||||||
Effect { skill: Skill, effect: Effect, duration: u8 },
|
|
||||||
AoeSkill { skill: Skill },
|
AoeSkill { skill: Skill },
|
||||||
Skill { skill: Skill },
|
Skill { skill: Skill },
|
||||||
Removal { effect: Effect },
|
Effect { skill: Skill, effect: Effect, duration: u8, construct_effects: Vec<ConstructEffect> },
|
||||||
|
Removal { effect: Effect, construct_effects: Vec<ConstructEffect> },
|
||||||
TargetKo { skill: Skill },
|
TargetKo { skill: Skill },
|
||||||
// skill not necessary but makes it neater as all events are arrays in js
|
// skill not necessary but makes it neater as all events are arrays in js
|
||||||
Ko { skill: Skill },
|
Ko { skill: Skill },
|
||||||
@ -1539,7 +1539,8 @@ fn strangle_tick(source: &mut Construct, target: &mut Construct, mut results: Re
|
|||||||
.position(|e| e.effect == Effect::Strangling)
|
.position(|e| e.effect == Effect::Strangling)
|
||||||
.expect("no strangling on construct");
|
.expect("no strangling on construct");
|
||||||
source.effects.remove(i);
|
source.effects.remove(i);
|
||||||
results.push(Resolution::new(source, source).event(Event::Removal { effect: Effect::Strangling }));
|
results.push(Resolution::new(source, source)
|
||||||
|
.event(Event::Removal { effect: Effect::Strangling, construct_effects: target.effects.clone() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
@ -1877,7 +1878,8 @@ fn purge(source: &mut Construct, target: &mut Construct, mut results: Resolution
|
|||||||
.iter()
|
.iter()
|
||||||
.position(|ce| ce.effect.category() == EffectCategory::Buff) {
|
.position(|ce| ce.effect.category() == EffectCategory::Buff) {
|
||||||
let ce = target.effects.remove(i);
|
let ce = target.effects.remove(i);
|
||||||
results.push(Resolution::new(source, target).event(Event::Removal { effect: ce.effect }));
|
results.push(Resolution::new(source, target)
|
||||||
|
.event(Event::Removal { effect: ce.effect, construct_effects: target.effects.clone() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
@ -1890,7 +1892,8 @@ fn purify(source: &mut Construct, target: &mut Construct, mut results: Resolutio
|
|||||||
.iter()
|
.iter()
|
||||||
.position(|ce| ce.effect.category() == EffectCategory::Debuff) {
|
.position(|ce| ce.effect.category() == EffectCategory::Debuff) {
|
||||||
let ce = target.effects.remove(i);
|
let ce = target.effects.remove(i);
|
||||||
results.push(Resolution::new(source, target).event(Event::Removal { effect: ce.effect }));
|
results.push(Resolution::new(source, target)
|
||||||
|
.event(Event::Removal { effect: ce.effect, construct_effects: target.effects.clone() }));
|
||||||
target.deal_green_damage(skill, amount)
|
target.deal_green_damage(skill, amount)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
|
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
|
||||||
@ -2092,7 +2095,7 @@ mod tests {
|
|||||||
|
|
||||||
let Resolution { source: _, target: _, event } = results.remove(0);
|
let Resolution { source: _, target: _, event } = results.remove(0);
|
||||||
match event {
|
match event {
|
||||||
Event::Effect { effect, skill: _, duration: _ } => assert_eq!(effect, Effect::Siphon),
|
Event::Effect { effect, skill: _, duration: _, construct_effects: _ } => assert_eq!(effect, Effect::Siphon),
|
||||||
_ => panic!("not siphon"),
|
_ => panic!("not siphon"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user