Merge branch 'master' of ssh://cryps.gg:40022/~/cryps
This commit is contained in:
commit
a6e91a1442
@ -208,20 +208,7 @@ class CombatCryps extends Phaser.Scene {
|
||||
}
|
||||
|
||||
if (key === 'crypStatusUpdate' && data) {
|
||||
const targetCryp = this.cryps.children.entries
|
||||
.find(c => c.cryp.id === data.id);
|
||||
|
||||
if (this.phase === 'Skill') {
|
||||
targetCryp.statusText.text = data.target === targetCryp.cryp.account
|
||||
? `${data.skill} on ally team`
|
||||
: `${data.skill} on enemy team`;
|
||||
}
|
||||
|
||||
if (this.phase === 'Target') {
|
||||
const sourceCryp = this.cryps.children.entries
|
||||
.find(c => c.cryp.id === data.skill.source_cryp_id);
|
||||
targetCryp.statusText.text = `${sourceCryp.cryp.name} ${data.skill.skill} ${targetCryp.cryp.name}`;
|
||||
}
|
||||
this.updateCrypStatus(data);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -260,6 +247,23 @@ class CombatCryps extends Phaser.Scene {
|
||||
if (crypId) this.cryps.children.entries.find(c => c.cryp.id === crypId).select();
|
||||
}
|
||||
|
||||
updateCrypStatus(status) {
|
||||
const targetCryp = this.cryps.children.entries
|
||||
.find(c => c.cryp.id === status.id);
|
||||
|
||||
if (this.phase === 'Skill') {
|
||||
targetCryp.statusText.text = status.target === targetCryp.cryp.account
|
||||
? `${status.skill} on ally team`
|
||||
: `${status.skill} on enemy team`;
|
||||
}
|
||||
|
||||
if (this.phase === 'Target') {
|
||||
const sourceCryp = this.cryps.children.entries
|
||||
.find(c => c.cryp.id === status.skill.source_cryp_id);
|
||||
targetCryp.statusText.text = `${sourceCryp.cryp.name} ${status.skill.skill} ${targetCryp.cryp.name}`;
|
||||
}
|
||||
}
|
||||
|
||||
cleanUp() {
|
||||
this.registry.events.off('changedata', this.updateData);
|
||||
this.scene.remove();
|
||||
|
||||
@ -24,8 +24,6 @@ class Combat extends Phaser.Scene {
|
||||
aztecImg.onload = () => {
|
||||
this.textures.addAtlas('aztec', aztecImg, aztecAtlas);
|
||||
};
|
||||
// this.textures.addBase64('alk', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/magmar.png')).toString('base64')}`);
|
||||
// this.textures.addBase64('magmar', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/magmar.png')).toString('base64')}`);
|
||||
this.load.image('proj', 'https://labs.phaser.io/assets/sprites/bullet.png');
|
||||
this.load.image('blue', 'https://labs.phaser.io/assets/particles/blue.png');
|
||||
this.load.image('green', 'https://labs.phaser.io/assets/particles/green.png');
|
||||
|
||||
@ -44,6 +44,16 @@ class GameList extends Phaser.GameObjects.Group {
|
||||
.text(pve.getCenter().x, pve.getCenter().y, 'new PVE\ngame', TEXT.HEADER)
|
||||
.setOrigin(0.5, 0.5));
|
||||
|
||||
const boss = list.add
|
||||
.rectangle(X, GAME_LIST.y(2), WIDTH, HEIGHT, 0x441122)
|
||||
.setInteractive()
|
||||
.setOrigin(0);
|
||||
|
||||
this.add(list.add
|
||||
.text(boss.getCenter().x, boss.getCenter().y, 'new Boss\ngame', TEXT.HEADER)
|
||||
.setOrigin(0.5, 0.5));
|
||||
|
||||
|
||||
const refresh = list.add
|
||||
.rectangle(X + WIDTH, GAME_LIST.y(1), WIDTH, HEIGHT, 0x000044)
|
||||
.setInteractive()
|
||||
@ -88,9 +98,16 @@ class GameList extends Phaser.GameObjects.Group {
|
||||
pve.on('pointerdown', () => {
|
||||
const team = cryps.filter(c => c.active).map(c => c.id);
|
||||
if (team.length === 0) return false;
|
||||
return ws.sendGamePve(team);
|
||||
return ws.sendGamePve(team, 'normal');
|
||||
});
|
||||
|
||||
boss.on('pointerdown', () => {
|
||||
const team = cryps.filter(c => c.active).map(c => c.id);
|
||||
if (team.length === 0) return false;
|
||||
return ws.sendGamePve(team, 'boss');
|
||||
});
|
||||
|
||||
|
||||
refresh.on('pointerdown', () => {
|
||||
return ws.sendGameJoinableList();
|
||||
});
|
||||
|
||||
@ -64,8 +64,8 @@ function createSocket(events) {
|
||||
send({ method: 'game_state', params: { id } });
|
||||
}
|
||||
|
||||
function sendGamePve(crypIds) {
|
||||
send({ method: 'game_pve', params: { cryp_ids: crypIds } });
|
||||
function sendGamePve(crypIds, mode) {
|
||||
send({ method: 'game_pve', params: { cryp_ids: crypIds, mode } });
|
||||
}
|
||||
|
||||
function sendGamePvp(crypIds) {
|
||||
|
||||
@ -753,6 +753,32 @@ fn generate_mob(lvl: u8) -> Cryp {
|
||||
|
||||
}
|
||||
|
||||
fn generate_mob_team(mode: String, cryps: &Vec<Cryp>) -> Team {
|
||||
|
||||
let mut mob_team = Team::new(Uuid::nil());
|
||||
|
||||
// Default settings
|
||||
let mut team_size = 1;
|
||||
let mut mob_lvl = 1;
|
||||
|
||||
// Modify the NPC cryps for game mode settings
|
||||
if (mode == "normal") {
|
||||
team_size = cryps.len();
|
||||
mob_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl;
|
||||
} else if (mode == "boss") {
|
||||
mob_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl + 2;
|
||||
}
|
||||
|
||||
// Generate and return the NPC team based on settings
|
||||
let mobs = iter::repeat_with(|| generate_mob(mob_lvl).set_account(Uuid::nil()))
|
||||
.take(team_size)
|
||||
.collect::<Vec<Cryp>>();
|
||||
mob_team.set_cryps(mobs);
|
||||
|
||||
return mob_team;
|
||||
|
||||
}
|
||||
|
||||
pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
||||
let cryps = params.cryp_ids
|
||||
.iter()
|
||||
@ -773,19 +799,13 @@ pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account)
|
||||
.set_team_size(cryps.len());
|
||||
|
||||
// create the mob team
|
||||
let mut mob_team = Team::new(Uuid::nil());
|
||||
let mob_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl;
|
||||
let mobs = iter::repeat_with(|| generate_mob(mob_lvl).set_account(Uuid::nil()))
|
||||
.take(cryps.len())
|
||||
.collect::<Vec<Cryp>>();
|
||||
let mut mob_team = generate_mob_team(params.mode, &cryps);
|
||||
|
||||
// add the players
|
||||
let mut plr_team = Team::new(account.id);
|
||||
plr_team
|
||||
.set_cryps(cryps);
|
||||
|
||||
mob_team
|
||||
.set_cryps(mobs);
|
||||
|
||||
game
|
||||
.team_add(plr_team)?
|
||||
|
||||
@ -395,6 +395,7 @@ struct GamePveMsg {
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct GamePveParams {
|
||||
pub cryp_ids: Vec<Uuid>,
|
||||
pub mode: String,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user