main.rs 750 B

1234567891011121314151617181920212223242526272829
  1. use moonmud::*;
  2. fn main() {
  3. let o: Option<Object> = Object::load_player_by_name(&"Test Player".to_string());
  4. match o {
  5. Some(o) => {
  6. println!("{:?}", o);
  7. }
  8. None => {
  9. let mut o = Object::default();
  10. o.id = next_id();
  11. o.kind = Kind::Player;
  12. o.name = "Test Player".to_string();
  13. o.set_password(&"12345".to_string());
  14. o.health = 10;
  15. o.max_health = 10;
  16. o.build = 1;
  17. o.max_build = 3;
  18. o.inv.add_one(1);
  19. o.inv.add(2, 2);
  20. if !o.save() {
  21. eprintln!("Failed saving?");
  22. } else {
  23. println!("{:?}", o);
  24. }
  25. }
  26. }
  27. }