server test is working :)

This commit is contained in:
Rusty Striker 2024-09-30 18:44:36 +03:00
parent 9189d9cd88
commit dd34317d14
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
9 changed files with 249 additions and 166 deletions

View file

@ -1,77 +1,23 @@
# WTF how do i implement a game???
## Things you need from a game
## Client todo
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
[ ] implement tavern functions
[ ] token drag & drop
[ ] Chat
[ ] Send new chat messages
[ ] recv new chat messages
[ ] roll a die when chat message requests that
[ ] figure out how to zoom on the mouse instead of the center of the div
[ ] data reqs
[ ]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,
}
```
## Server todo
[ ] impl different requests
[ ] actual normal login
[ ] allow sending of old info
[ ] chat history
[ ] send texture (map/token/image)
[ ] force show something
[ ] mouse ping (ideally multiple types)
[ ] data reqs