smarter joinable algo
This commit is contained in:
parent
79f96a2ee0
commit
1f180402b3
@ -3,6 +3,7 @@ const Phaser = require('phaser');
|
||||
const Header = require('./header');
|
||||
const Menu = require('./menu');
|
||||
const Combat = require('./combat');
|
||||
const Missions = require('./missions');
|
||||
|
||||
function renderCryps() {
|
||||
const config = {
|
||||
@ -35,6 +36,11 @@ function renderCryps() {
|
||||
if (!data || game.registry.get('inGame')) return false;
|
||||
return game.scene.add('Combat', Combat, true);
|
||||
}
|
||||
|
||||
if (key === 'zone') {
|
||||
return game.scene.add('Missions', Missions, true, data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const Phaser = require('phaser');
|
||||
const Missions = require('./missions');
|
||||
|
||||
const {
|
||||
TEXT,
|
||||
@ -123,7 +122,6 @@ class MenuGameList extends Phaser.Scene {
|
||||
});
|
||||
|
||||
zones.on('pointerdown', () => {
|
||||
this.scene.add('Missions', Missions, true);
|
||||
return ws.sendAccountZone();
|
||||
});
|
||||
|
||||
|
||||
@ -15,8 +15,7 @@ class Missions extends Phaser.Scene {
|
||||
this.load.image('eye', 'https://labs.phaser.io/assets/particles/green-orb.png');
|
||||
}
|
||||
|
||||
create() {
|
||||
const zone = this.registry.get('zone');
|
||||
create(zone) {
|
||||
if (!zone) return false;
|
||||
|
||||
this.scene.manager.add('MissionControls', MissionControls, true);
|
||||
|
||||
@ -208,11 +208,8 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
// now check the graph for connectedness
|
||||
// get all the nodes that have been successfully completed
|
||||
let mut filtered = graph.clone();
|
||||
filtered.retain_nodes(|g, i| {
|
||||
match g.node_weight(i) {
|
||||
let success_indices = graph.node_indices().filter(|i| {
|
||||
match graph.node_weight(*i) {
|
||||
Some(encounter) => encounter.success,
|
||||
None => panic!("no weight for {:?}", i),
|
||||
}
|
||||
@ -221,7 +218,7 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool {
|
||||
// if a node is a neighbour of that graph
|
||||
// and hasn't been attempted
|
||||
// it is joinable
|
||||
for i in filtered.node_indices() {
|
||||
for i in success_indices {
|
||||
match graph.neighbors(i).find(|n| *n == target_index) {
|
||||
Some(_n) => return true,
|
||||
None => continue,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user