fix score
This commit is contained in:
30
src/main.rs
30
src/main.rs
@@ -49,6 +49,8 @@ fn main() {
|
||||
if let Some(i) = rot_index {
|
||||
game.last_rotation = Some((r, i));
|
||||
}
|
||||
} else {
|
||||
game.last_rotation = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,8 +191,8 @@ struct Current {
|
||||
t_spin: Option<TSpin>,
|
||||
lines: u32,
|
||||
points: u32,
|
||||
perfect: bool,
|
||||
back_to_back: bool,
|
||||
perfect: bool,
|
||||
}
|
||||
|
||||
impl Current {
|
||||
@@ -199,8 +201,8 @@ impl Current {
|
||||
t_spin: None,
|
||||
lines: 0,
|
||||
points: 0,
|
||||
perfect: false,
|
||||
back_to_back: false,
|
||||
perfect: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,6 +314,7 @@ fn points(
|
||||
combo: &mut i32,
|
||||
prev_difficult: &mut bool,
|
||||
) {
|
||||
current.points = 0;
|
||||
if current.lines == 0 {
|
||||
*combo = -1;
|
||||
if current.t_spin.is_none() {
|
||||
@@ -331,22 +334,18 @@ fn points(
|
||||
};
|
||||
current.points += combo_mul * 50 * level;
|
||||
|
||||
let mut perfect = true;
|
||||
current.perfect = true;
|
||||
'outer: for line in block_grid.0 {
|
||||
for b in line {
|
||||
if b.is_some() {
|
||||
perfect = false;
|
||||
current.perfect = false;
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current.perfect = perfect;
|
||||
|
||||
let mut points = 0;
|
||||
|
||||
if perfect {
|
||||
points += match current.lines {
|
||||
if current.perfect {
|
||||
current.points += match current.lines {
|
||||
1 => 800 * level,
|
||||
2 => 1200 * level,
|
||||
3 => 1800 * level,
|
||||
@@ -355,7 +354,7 @@ fn points(
|
||||
};
|
||||
}
|
||||
|
||||
points += match current.t_spin {
|
||||
current.points += match current.t_spin {
|
||||
Some(TSpin::Proper) => match current.lines {
|
||||
0 => 400 * level,
|
||||
1 => 800 * level,
|
||||
@@ -379,23 +378,26 @@ fn points(
|
||||
};
|
||||
|
||||
match (current.lines, ¤t.t_spin) {
|
||||
(1..=3, _) => {
|
||||
current.back_to_back = false;
|
||||
*prev_difficult = false;
|
||||
}
|
||||
(4, _) => {
|
||||
if *prev_difficult {
|
||||
points += points / 2;
|
||||
current.points += current.points / 2;
|
||||
current.back_to_back = true;
|
||||
}
|
||||
*prev_difficult = true;
|
||||
}
|
||||
(1.., Some(_)) => {
|
||||
if *prev_difficult {
|
||||
points += points / 2;
|
||||
current.points += current.points / 2;
|
||||
current.back_to_back = true;
|
||||
}
|
||||
*prev_difficult = true;
|
||||
}
|
||||
_ => *prev_difficult = false,
|
||||
}
|
||||
current.points = points;
|
||||
}
|
||||
|
||||
fn handle_action(
|
||||
|
||||
Reference in New Issue
Block a user