combat log"
This commit is contained in:
parent
08b830320a
commit
a42ef53c6d
@ -1,9 +1,14 @@
|
||||
const preact = require('preact');
|
||||
|
||||
function CrypPanel({ battle }) {
|
||||
if (!battle) return <div>...</div>;
|
||||
return (
|
||||
<div className="">
|
||||
{JSON.stringify(battle)}
|
||||
{JSON.stringify(battle.a)}
|
||||
{JSON.stringify(battle.b)}
|
||||
<ul>
|
||||
{battle.log.map((l, i) => (<li key={i} >{l}</li>))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -50,4 +50,27 @@ gem td style attr combinations
|
||||
techno artists for the soundtrack
|
||||
|
||||
slimey
|
||||
ghostly
|
||||
ghostly
|
||||
|
||||
|
||||
|
||||
* 1: Fighting against human nature is a losing battle
|
||||
* 2: Aesthetics matter
|
||||
* 3: Resonance is important
|
||||
* 4: Make use of piggybacking
|
||||
* 5: Don't confuse "interesting" with "fun"
|
||||
* 6: Understand what emotion your game is trying to evoke
|
||||
* 7: Allow the players the ability to make the game personal
|
||||
* 8: The details are where the players fall in love with your game
|
||||
* 9: Allow your players to have a sense of ownership
|
||||
* 10: Leave room for the player to explore
|
||||
* 11: If everyone likes your game, but no one loves it, it will fail
|
||||
* 12: Don't design to prove you can do something
|
||||
* 13: Make the fun part also the correct strategy to win
|
||||
* 14: Don't be afraid to be blunt
|
||||
* 15: Design the component for its intended audience
|
||||
* 16: Be more afraid of boring your players than challenging them
|
||||
* 17: You don't have to change much to change everything
|
||||
* 18: Restrictions breed creativity
|
||||
* 19: Your audience is good at recognizing problems and bad at solving them
|
||||
* 20: All the lessons connect
|
||||
@ -16,6 +16,7 @@ use cryp::Cryp;
|
||||
pub struct Battle {
|
||||
pub a: Cryp,
|
||||
pub b: Cryp,
|
||||
pub log: Vec<String>,
|
||||
}
|
||||
|
||||
impl Battle {
|
||||
@ -23,6 +24,7 @@ impl Battle {
|
||||
return Battle {
|
||||
a: a.clone(),
|
||||
b: b.clone(),
|
||||
log: vec![],
|
||||
};
|
||||
}
|
||||
|
||||
@ -35,12 +37,15 @@ impl Battle {
|
||||
panic!("{:?} is finished", self);
|
||||
}
|
||||
|
||||
let a_turn = self.a.turn();
|
||||
let b_turn = self.b.turn();
|
||||
let mut a_turn = self.a.turn();
|
||||
let mut b_turn = self.b.turn();
|
||||
|
||||
self.a.assign_dmg(&self.b, &a_turn, &b_turn);
|
||||
self.b.assign_dmg(&self.a, &b_turn, &a_turn);
|
||||
|
||||
self.log.append(&mut a_turn.log);
|
||||
self.log.append(&mut b_turn.log);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@ -38,25 +38,25 @@ impl Stat {
|
||||
self
|
||||
}
|
||||
|
||||
fn roll(&self, c: &Cryp) -> Roll {
|
||||
fn roll(&self, c: &Cryp, log: &mut Vec<String>) -> Roll {
|
||||
let mut rng = thread_rng();
|
||||
let base: u64 = rng.gen();
|
||||
|
||||
let mut roll = Roll { kind: self.kind, base, result: base };
|
||||
|
||||
println!("{:?}", self.kind);
|
||||
println!("{:064b} <- base roll", base);
|
||||
log.push(format!("{:?}", self.kind));
|
||||
log.push(format!("{:064b} <- base roll", base));
|
||||
|
||||
// apply skills
|
||||
roll = c.skills.iter().fold(roll, |roll, s| s.apply(roll));
|
||||
|
||||
// finally combine with stat
|
||||
println!("{:064b} <- finalised", roll.result);
|
||||
log.push(format!("{:064b} <- finalised", roll.result));
|
||||
roll.result = roll.result & self.value;
|
||||
|
||||
println!("{:064b} & <- attribute roll", self.value);
|
||||
println!("{:064b} = {:?}", roll.result, roll.result);
|
||||
println!("");
|
||||
log.push(format!("{:064b} & <- attribute roll", self.value));
|
||||
log.push(format!("{:064b} = {:?}", roll.result, roll.result));
|
||||
log.push(format!(""));
|
||||
|
||||
return roll;
|
||||
}
|
||||
@ -70,6 +70,7 @@ impl Stat {
|
||||
pub struct Turn {
|
||||
pub dmg: Roll,
|
||||
pub def: Roll,
|
||||
pub log: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
@ -143,11 +144,12 @@ impl Cryp {
|
||||
}
|
||||
|
||||
pub fn turn(&self) -> Turn {
|
||||
// println!("{:?}'s turn:", c.name);
|
||||
let dmg = self.dmg.roll(self);
|
||||
let def = self.def.roll(self);
|
||||
let mut log = vec![format!("{:?}'s turn:", self.name)];
|
||||
|
||||
return Turn { dmg, def }
|
||||
let dmg = self.dmg.roll(self, &mut log);
|
||||
let def = self.def.roll(self, &mut log);
|
||||
|
||||
return Turn { dmg, def, log }
|
||||
}
|
||||
|
||||
pub fn create(mut self) -> Cryp {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user