Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taiko Game Improvements (v0.1.0) #21

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ Cargo.lock

#/target
.DS_Store

taiko-game/profile.csv
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"tja",
"taiko-core",
"taiko-game",
"taiko-streaming",
]

[profile.release]
Expand Down
39 changes: 39 additions & 0 deletions taiko-core/src/taiko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ pub enum Hit {
Kat,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub struct Personalization {
pub course: u8,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub enum Judgement {
Great,
Expand Down Expand Up @@ -156,6 +161,24 @@ pub struct OutputState {

/// Display state
pub display: Vec<CalculatedNote>,

// Current drumroll state
pub drumroll: Option<u32>,
}

impl Default for OutputState {
fn default() -> Self {
Self {
finished: false,
score: 0,
current_combo: 0,
max_combo: 0,
gauge: 0.0,
judgement: None,
display: vec![],
drumroll: None,
}
}
}

#[derive(Clone, PartialEq, PartialOrd, Debug, Serialize, Deserialize)]
Expand All @@ -176,6 +199,7 @@ pub trait TaikoEngine<H> {
fn finalize(&self) -> Final;
}

#[derive(Clone)]
pub struct DefaultTaikoEngine {
rhythm: Rhythm<CalculatedNote>,

Expand Down Expand Up @@ -380,6 +404,20 @@ impl TaikoEngine<Hit> for DefaultTaikoEngine {
.cloned()
.collect::<Vec<_>>();

let drumroll = available_display.first().and_then(|note| {
if note.variant() == TaikoNoteVariant::Both {
let (head, _) = note.position(input.time).unwrap();
// if can be hit
if head < 0.1 && note.inner.volume < 1000 && note.inner.volume > 0 {
Some(note.inner.volume as u32)
} else {
None
}
} else {
None
}
});

let mut display = self.passed_display.clone();
display.extend(available_display);

Expand All @@ -391,6 +429,7 @@ impl TaikoEngine<Hit> for DefaultTaikoEngine {
gauge: self.gauge,
judgement,
display,
drumroll,
}
}

Expand Down
21 changes: 16 additions & 5 deletions taiko-game/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "taiko-game"
description = "A taiko game written in Rust."
version = "0.0.8"
version = "0.1.0"
license = "MIT"
authors = ["JacobLinCool <jacob@csie.cool>"]
homepage = "https://github.com/JacobLinCool/rhythm-rs"
Expand All @@ -18,15 +18,21 @@ rhythm-core = { path = "../rhythm-core", version = "0.2.0" }
tja = { path = "../tja", version = "0.2.3" }
taiko-core = { path = "../taiko-core", version = "0.0.2" }
better-panic = "0.3.0"
clap = { version = "4.5.4", features = ["derive", "cargo", "wrap_help", "unicode", "string", "unstable-styles"] }
clap = { version = "4.5.4", features = [
"derive",
"cargo",
"wrap_help",
"unicode",
"string",
"unstable-styles",
] }
color-eyre = "0.6.3"
config = "0.14.0"
crossterm = { version = "0.27.0", features = ["serde", "event-stream"] }
crossterm = { version = "0.28.1", features = ["serde", "event-stream"] }
derive_deref = "1.1.1"
directories = "5.0.1"
futures = "0.3.30"
human-panic = "2.0.0"
lazy_static = "1.4.0"
log = "0.4.21"
pretty_assertions = "1.4.0"
ratatui = { version = "=0.26.1", features = ["serde", "macros"] }
Expand All @@ -44,6 +50,11 @@ anyhow = "1.0.82"
encoding_rs = "0.8.34"
kira = "0.8.7"
glob = "0.3.1"
bore-cli = "0.5.1"
taiko-streaming = { version = "0.0.0", path = "../taiko-streaming" }
sha2 = "0.10.8"
once_cell = "1.19.0"
csv = "1.3.0"

[build-dependencies]
vergen = { version = "8.3.1", features = [ "build", "git", "gitoxide", "cargo" ]}
vergen = { version = "8.3.1", features = ["build", "git", "gitoxide", "cargo"] }
20 changes: 20 additions & 0 deletions taiko-game/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@ A taiko game written in Rust.
- `DON`: `' ' | 'f' | 'g' | 'h' | 'j' | 'c' | 'v' | 'b' | 'n' | 'm'`
- `KAT`: `'d' | 's' | 'a' | 't' | 'r' | 'e' | 'w' | 'q' | 'x' | 'z' | 'k' | 'l' | ';' | '\'' | 'y' | 'u' | 'i' | 'o' | 'p' | ',' | '.' | '/'`
- `CANCEL`: `ESC`

```mermaid
graph TD
LocalInput[Local Input Device]
RemoteInput[Remote Input Device]
InputMixer[Input Mixer]
GameEngine[Game Engine]
UI[UI]
LocalOutput[Local Output Device]
LocalPeer[Local Peer]
RemotePeer[Remote Peer]

LocalInput --> |Key Event| InputMixer
RemoteInput --> |Key Event| RemotePeer
RemotePeer --> |Data| LocalPeer
LocalPeer --> |Key Event| InputMixer
InputMixer --> |Key Event| GameEngine
GameEngine --> |State| UI
UI --> |Frame| LocalOutput
```
17 changes: 2 additions & 15 deletions taiko-game/src/action.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
use std::{fmt, string::ToString};
use crate::uix::Page;

use serde::{
de::{self, Deserializer, Visitor},
Deserialize, Serialize,
};
use strum::Display;

use crate::app::Page;

#[derive(Debug, Clone, PartialEq, Eq, Display)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Action {
Tick,
Render,
Resize(u16, u16),
Suspend,
Resume,
Quit,
Refresh,
Error(String),
Help,
Switch(Page),
}
Loading