Browse Source

initial present stuff

presents
andy 4 years ago
parent
commit
a77b9874ff
  1. 7
      src/bin/main.rs
  2. 3
      src/entity/gateway/postgres/models.rs
  3. 26
      src/entity/item/weapon.rs
  4. 1
      src/login/character.rs
  5. 5
      src/ship/drops/generic_weapon.rs
  6. 1
      src/ship/drops/rare_drop_table.rs
  7. 1
      src/ship/shops/weapon.rs

7
src/bin/main.rs

@ -84,6 +84,7 @@ fn main() {
special: None,
attrs: [None, None, None],
tekked: true,
wrapping: None,
}
),
location: item::ItemLocation::Bank {
@ -119,6 +120,7 @@ fn main() {
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}),
None,],
tekked: false,
wrapping: Some(item::weapon::WrappingPaper::Black_Yellow),
}
),
location: ItemLocation::Inventory {
@ -136,6 +138,7 @@ fn main() {
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}),
None,],
tekked: true,
wrapping: None,
}
),
location: ItemLocation::Inventory {
@ -153,6 +156,7 @@ fn main() {
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
None,],
tekked: true,
wrapping: None,
}
),
location: ItemLocation::Inventory {
@ -170,6 +174,7 @@ fn main() {
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
None,],
tekked: true,
wrapping: None,
}
),
location: ItemLocation::Inventory {
@ -187,6 +192,7 @@ fn main() {
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),],
tekked: true,
wrapping: None,
}
),
location: ItemLocation::Inventory {
@ -251,6 +257,7 @@ fn main() {
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 80}),
None,],
tekked: false,
wrapping: None,
}
),
location: ItemLocation::Bank {

3
src/entity/gateway/postgres/models.rs

@ -286,6 +286,7 @@ pub struct PgWeapon {
grind: u8,
attrs: HashMap<weapon::Attribute, i8>,
tekked: bool,
wrapping: Option<weapon::WrappingPaper>,
}
impl From<weapon::Weapon> for PgWeapon {
@ -296,6 +297,7 @@ impl From<weapon::Weapon> for PgWeapon {
grind: other.grind,
attrs: other.attrs.iter().flatten().map(|attr| (attr.attr, attr.value)).collect(),
tekked: other.tekked,
wrapping: other.wrapping,
}
}
}
@ -316,6 +318,7 @@ impl Into<weapon::Weapon> for PgWeapon {
grind: self.grind,
attrs: attrs,
tekked: self.tekked,
wrapping: self.wrapping,
}
}
}

26
src/entity/item/weapon.rs

@ -1454,7 +1454,7 @@ pub enum WeaponModifier {
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum WrappingPaper {
White_Pink, // 0
Yellow_Blue,
@ -1499,8 +1499,7 @@ pub struct Weapon {
pub grind: u8,
pub attrs: [Option<WeaponAttribute>; 3],
pub tekked: bool,
pub modifiers: Vec<WeaponModifier>,
pub wrapped: Option<WrappingPaper>,
pub wrapping: Option<WrappingPaper>,
}
@ -1512,8 +1511,7 @@ impl Weapon {
grind: 0,
attrs: [None; 3],
tekked: true,
modifiers: Vec::new(),
wrapped: None,
wrapping: None,
}
}
@ -1568,9 +1566,9 @@ impl Weapon {
result[3] = self.grind;
result[4] = self.special.map(|s| s.value()).unwrap_or(0);
if self.wrapped.is_some() {
if self.wrapping.is_some() {
result[4] += 0x40;
result[5] = self.wrapped.unwrap().value();
result[5] = self.wrapping.unwrap().value();
};
if self.tekked == false {
@ -1590,16 +1588,21 @@ impl Weapon {
if w.is_ok() {
let mut s = None;
let mut t = true;
let mut p = None; // wrapping paper
let g = data[3];
if data[4] >= 0x81 && data[4] <= 0xA8 {
if data[4] & 0x80 == 0x80 {
s = WeaponSpecial::from(data[4] - 0x80);
t = false;
}
else if data[4] >= 0x01 && data[4] <= 0x28 {
s = WeaponSpecial::from(data[4]);
t = true;
if data[4] & 0x40 == 0x40 {
p = WrappingPaper::from(data[5]);
}
// else if data[4] >= 0x01 && data[4] <= 0x28 {
// s = WeaponSpecial::from(data[4]);
// t = true;
// }
// else {
// return Err(ItemParseError::InvalidSpecial)
// }
@ -1632,6 +1635,7 @@ impl Weapon {
a[2],
],
tekked: t,
wrapping: p,
})
}
else {

1
src/login/character.rs

@ -220,6 +220,7 @@ async fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAc
special: None,
attrs: [None; 3],
tekked: true,
wrapping: None,
}),
location: ItemLocation::Inventory {
character_id: character.id,

5
src/ship/drops/generic_weapon.rs

@ -503,6 +503,7 @@ impl GenericWeaponTable {
grind: weapon_grind as u8,
attrs: weapon_attributes,
tekked: weapon_special.is_none(),
wrapping: None,
}))
}
}
@ -524,6 +525,7 @@ mod test {
grind: 0,
attrs: [None, None, None],
tekked: true,
wrapping: None,
})));
let gwt = GenericWeaponTable::new(Episode::One, Difficulty::Hard, SectionID::Skyly);
@ -533,6 +535,7 @@ mod test {
grind: 2,
attrs: [None, None, None],
tekked: true,
wrapping: None,
})));
let gwt = GenericWeaponTable::new(Episode::One, Difficulty::VeryHard, SectionID::Skyly);
@ -542,6 +545,7 @@ mod test {
grind: 0,
attrs: [None, None, None],
tekked: false,
wrapping: None,
})));
let gwt = GenericWeaponTable::new(Episode::One, Difficulty::Ultimate, SectionID::Skyly);
@ -551,6 +555,7 @@ mod test {
grind: 0,
attrs: [Some(WeaponAttribute {attr: Attribute::ABeast, value: 30}), Some(WeaponAttribute {attr: Attribute::Dark, value: 30}), None],
tekked: true,
wrapping: None,
})));
}
}

1
src/ship/drops/rare_drop_table.rs

@ -104,6 +104,7 @@ impl RareDropTable {
grind: 0,
attrs: self.attribute_table.generate_rare_attributes(map_area, rng),
tekked: false,
wrapping: None,
})
},

1
src/ship/shops/weapon.rs

@ -142,6 +142,7 @@ impl ShopItem for WeaponShopItem {
grind: self.grind as u8,
attrs: [self.attributes[0], self.attributes[1], None],
tekked: true,
wrapping: None,
}
)
}

Loading…
Cancel
Save