i did some stuff, honestly it starts to build pretty well if i might sayy
This commit is contained in:
parent
22319e84a1
commit
9189d9cd88
22 changed files with 689 additions and 176 deletions
77
readme.md
Normal file
77
readme.md
Normal file
|
@ -0,0 +1,77 @@
|
|||
# WTF how do i implement a game???
|
||||
|
||||
## Things you need from a game
|
||||
|
||||
Characters and character sheet:
|
||||
[x] Stats and items: get/set/display
|
||||
[ ] Actions (broken into different tabs, aka: `(&self) -> Vec<InteractionDefinition>`)
|
||||
[ ] Token status: status icons (with tooltip ffs)/light produced/vision distance(in light level)
|
||||
[ ] Apply Action `(&mut self, InteractionResult) -> ()`
|
||||
Spells and items
|
||||
|
||||
[ ]Turn based combat callbakcs:
|
||||
[ ] Start of turn - `(&mut self) -> Vec<Message>`
|
||||
[ ] End of turn
|
||||
|
||||
|
||||
InteractionDef -> Player uses -> Interaction in chat (with actions) -> Rolls some dice -> Interaction
|
||||
|
||||
Shoot arrow def ->
|
||||
player A shoots B (rolls attack) -> I
|
||||
nteraction in chat (with Roll damage button) ->
|
||||
InteractionResult (damage/double/block/heal actions) ->
|
||||
Apply InteractionResult ()
|
||||
|
||||
```rust
|
||||
trait Action {}
|
||||
trait CS<A: Action> {
|
||||
|
||||
fn can_use_action(&self, action: &A) -> bool;
|
||||
}
|
||||
struct Game<'dec, 'dea, C: CS<A> + Serialize + Deserialize<'dec>, A: Action + Serialize + Deserialize<'dea>> {
|
||||
_a: std::marker::PhantomData<&'dea A>,
|
||||
_c: std::marker::PhantomData<&'dec C>,
|
||||
}
|
||||
impl<'dec, 'dea, C: CS<A> + Serialize + Deserialize<'dec>, A: Action + Serialize + Deserialize<'dea>> Game<'dec, 'dea, C, A> {
|
||||
fn read_spell(s: &'dea str) -> A {
|
||||
serde_json::de::from_str::<A>(s).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct Spell {
|
||||
pub mana: i32,
|
||||
}
|
||||
impl Action for Spell {}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct Sheet;
|
||||
impl CS<Spell> for Sheet {
|
||||
fn can_use_action(&self, action: &Spell) -> bool {
|
||||
action.mana > 10
|
||||
}
|
||||
}
|
||||
fn stupid() {
|
||||
let game = Game::<'_, '_, Sheet, Spell>::read_spell("aaaaaaaa");
|
||||
}
|
||||
```
|
||||
^^^ this looks mad isnt it, but it defines 3 traits, Action, Character sheet and game(which should be a trait actually)
|
||||
|
||||
1. Player connects
|
||||
2. Player gets character data (including all the relevant actions and such)
|
||||
3. Player acts
|
||||
|
||||
1. Player does action
|
||||
2. Action is printed to chat (with rolls and such)
|
||||
3. Action button is pressed (optional rolls)
|
||||
|
||||
fn use_action(&mut self, entry: &Entry, action: &Action) -> ChatMessage
|
||||
|
||||
```rust
|
||||
struct Action {
|
||||
pub name: String,
|
||||
pub roll_result: i32,
|
||||
}
|
||||
|
||||
```
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue