better node errors
This commit is contained in:
parent
b92a88280f
commit
f3eec0b0b1
@ -83,6 +83,15 @@ class MenuCrypList extends Phaser.Scene {
|
||||
const CRYP_STATS = [cryp.stamina, cryp.phys_dmg, cryp.spell_dmg];
|
||||
CRYP_STATS.forEach(crypStat);
|
||||
|
||||
const crypSkill = (skill, j) => {
|
||||
const SKILL_X = ROW_X;
|
||||
const SKILL_Y = ((j + 3) * TEXT_MARGIN) + ROW_Y + TEXT_MARGIN;
|
||||
|
||||
this.crypRows.add(this.add.text(SKILL_X, SKILL_Y, `${skill.skill}`, TEXT.NORMAL));
|
||||
};
|
||||
|
||||
cryp.skills.forEach(crypSkill);
|
||||
|
||||
const selectBtn = this.add
|
||||
.rectangle(0, ROW_Y + (ROW_HEIGHT * 0.9), ROW_WIDTH, ROW_HEIGHT / 10, FILL, 0.5)
|
||||
.setInteractive()
|
||||
|
||||
@ -12,9 +12,8 @@ strangle
|
||||
## NOW
|
||||
|
||||
* zones
|
||||
* differnt game types based on tag
|
||||
* open w/ item?
|
||||
* close
|
||||
* update on game finish
|
||||
|
||||
## SOON
|
||||
* aoe skills
|
||||
|
||||
@ -141,9 +141,8 @@ pub fn zone_update(zone: &Zone, tx: &mut Transaction) -> Result<(), Error> {
|
||||
pub fn zone_join(params: ZoneJoinParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
||||
let mut zone = zone_get(tx, params.zone_id)?;
|
||||
|
||||
if !node_joinable(&zone.graph, NodeIndex::from(params.node_id)) {
|
||||
return Err(err_msg("not not joinable"));
|
||||
}
|
||||
// check node joinable
|
||||
node_joinable(&zone.graph, NodeIndex::from(params.node_id))?;
|
||||
|
||||
let mut game = game_pve_new(params.cryp_ids, PveMode::Normal, tx, account)?;
|
||||
game.set_zone(zone.id, params.node_id);
|
||||
@ -197,7 +196,7 @@ pub fn create_zone_graph() -> ZoneGraph {
|
||||
return gr;
|
||||
}
|
||||
|
||||
pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool {
|
||||
pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> Result<(), Error> {
|
||||
// early return for already attempted
|
||||
{
|
||||
let target_encounter = match graph.node_weight(target_index) {
|
||||
@ -206,7 +205,7 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool {
|
||||
};
|
||||
|
||||
if target_encounter.game_id.is_some() {
|
||||
return false;
|
||||
return Err(err_msg("node already attempted"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,12 +221,12 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool {
|
||||
// it is joinable
|
||||
for i in success_indices {
|
||||
match graph.neighbors(i).find(|n| *n == target_index) {
|
||||
Some(_n) => return true,
|
||||
Some(_n) => return Ok(()),
|
||||
None => continue,
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
return Err(err_msg("node requirements not met"));
|
||||
}
|
||||
|
||||
pub fn node_finish(game: &Game, zone_id: Uuid, node_index: u32, tx: &mut Transaction) -> Result<Zone, Error> {
|
||||
@ -270,7 +269,7 @@ mod tests {
|
||||
#[test]
|
||||
fn zone_joinable_test() {
|
||||
let graph = create_zone_graph();
|
||||
assert!(node_joinable(&graph, NodeIndex::from(1)));
|
||||
assert!(!node_joinable(&graph, NodeIndex::from(2)));
|
||||
assert!(node_joinable(&graph, NodeIndex::from(1)).is_ok());
|
||||
assert!(node_joinable(&graph, NodeIndex::from(2)).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user