diff src/th06/enemy.rs @ 664:f08e8e3c6196

Use bitflags for the rank, instead of an u16.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 11 Aug 2019 19:55:45 +0200
parents 107bb5ca5cc8
children 965ecdbf0316
line wrap: on
line diff
--- a/src/th06/enemy.rs
+++ b/src/th06/enemy.rs
@@ -2,6 +2,7 @@
 
 use crate::th06::anm0::Anm0;
 use crate::th06::anm0_vm::{Sprite, AnmRunner};
+use crate::th06::ecl::Rank;
 use crate::th06::interpolator::{Interpolator1, Interpolator2};
 use crate::util::prng::Prng;
 use std::cell::RefCell;
@@ -60,18 +61,18 @@ pub struct Game {
     enemies: Vec<Rc<RefCell<Enemy>>>,
     anmrunners: Vec<Rc<RefCell<AnmRunner>>>,
     prng: Rc<RefCell<Prng>>,
-    rank: i32,
+    rank: Rank,
     difficulty: i32,
 }
 
 impl Game {
     /// Create said god struct.
-    pub fn new(prng: Rc<RefCell<Prng>>) -> Game {
+    pub fn new(prng: Rc<RefCell<Prng>>, rank: Rank) -> Game {
         Game {
             enemies: Vec::new(),
             anmrunners: Vec::new(),
             prng,
-            rank: 0,
+            rank,
             difficulty: 0,
         }
     }
@@ -262,7 +263,7 @@ impl Enemy {
         self.frame += 1;
     }
 
-    pub(crate) fn get_rank(&self) -> i32 {
+    pub(crate) fn get_rank(&self) -> Rank {
         let game = self.game.upgrade().unwrap();
         let game = game.borrow();
         game.rank