Browse Source

send the actual char into the lobby

pbs
jake 5 years ago
parent
commit
6d57d5d6fa
  1. 19
      src/ship/ship.rs

19
src/ship/ship.rs

@ -22,6 +22,8 @@ pub const SHIP_PORT: u16 = 23423;
#[derive(Debug)]
pub enum ShipError {
ClientNotFound(ClientId),
NoCharacterInSlot(ClientId, u32),
InvalidSlot(ClientId, u32),
}
#[derive(Debug)]
@ -68,7 +70,7 @@ impl SendServerPacket for SendShipPacket {
struct ClientState {
user: Option<UserAccount>,
characters: Option<[Option<Character>; 4]>,
character: Character,
session: Session,
block: u32,
}
@ -77,7 +79,7 @@ impl ClientState {
fn new() -> ClientState {
ClientState {
user: None,
characters: None,
character: Character::default(),
session: Session::new(),
block: 0,
}
@ -105,8 +107,14 @@ impl<EG: EntityGateway> ShipServerState<EG> {
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
response.guildcard = user.guildcard.map_or(24, |gc| gc) as u32;
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
client.user = Some(user);
client.session = pkt.session;
println!("SESSION {:?}", client.session);
let characters = self.entity_gateway.get_characters_by_user(&user);
client.character = characters
.get(pkt.session.character_slot as usize)
.ok_or(ShipError::InvalidSlot(id, pkt.session.character_slot as u32))?
.ok_or(ShipError::NoCharacterInSlot(id, pkt.session.character_slot as u32))?;
client.user = Some(user);
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(3))]
},
Err(err) => {
@ -120,11 +128,8 @@ impl<EG: EntityGateway> ShipServerState<EG> {
client.block = pkt.item as u32;
let mut fc = character::FullCharacter::default();
fc.character.hp = 4000;
fc.character.atp = 1200;
fc.character.lck = 1300;
fc.character = client.character.character;
//Ok(Vec::new())
Ok(vec![
SendShipPacket::FullCharacter(FullCharacter {
character: fc,

Loading…
Cancel
Save