let message: Message;
if(msg.startsWith('/server lmnop')) {
- if(msg === '/server lmnop refresh-monsters') {
- await createMonsters();
- message = broadcastMessage('server', 'Monster refresh!');
- }
- else if(msg === '/server lmnop refresh-cities') {
- await createAllCitiesAndLocations();
- message = broadcastMessage('server', 'Cities, Locations, and Paths refreshed!');
- }
- else if(msg === '/server lmnop refresh-shops') {
- await createShopItems();
- await createShopEquipment();
- message = broadcastMessage('server', 'Refresh shop items');
- }
- else {
- const str = msg.split('/server lmnop ')[1];
- if(str) {
- message = broadcastMessage('server', str);
+ try {
+ if(msg === '/server lmnop refresh-monsters') {
+ await createMonsters();
+ message = broadcastMessage('server', 'Monster refresh!');
+ }
+ else if(msg === '/server lmnop refresh-cities') {
+ await createAllCitiesAndLocations();
+ message = broadcastMessage('server', 'Cities, Locations, and Paths refreshed!');
+ }
+ else if(msg === '/server lmnop refresh-shops') {
+ await createShopItems();
+ await createShopEquipment();
+ message = broadcastMessage('server', 'Refresh shop items');
}
+ else {
+ const str = msg.split('/server lmnop ')[1];
+ if(str) {
+ message = broadcastMessage('server', str);
+ }
+ }
+ }
+ catch(e) {
+ io.to(cache.get(`socket:${req.player.id}`)).emit('chat', renderChatMessage(broadcastMessage('server', e.message)));
}
}
else if(msg === '/online') {
}
if(fight) {
- const data: MonsterForFight = {
- id: fight.id,
- hp: fight.hp,
- maxHp: fight.maxHp,
- name: fight.name,
- level: fight.level,
- fight_trigger: fight.fight_trigger
- };
const location = await getMonsterLocation(fight.ref_id);
-
- res.send(renderPlayerBar(req.player) + renderFightPreRound(data, true, location, closestTown));
+ res.send(renderPlayerBar(req.player) + renderFightPreRound(fight, true, location, closestTown));
}
else {
if(travelPlan) {
}
cache[fightBlockKey] = Date.now() + CONSTANT.FIGHT_ATTACK_DELAY;
- const monster = await loadMonsterWithFaction(req.player.id);
+ const monster = await loadMonsterFromFight(req.player.id);
if(!monster) {
res.send(Alert.ErrorAlert('Not in a fight'));
const fight = await createFight(req.player.id, monster, fightTrigger);
const location = await getService(monster.location_id);
-
- const data: MonsterForFight = {
- id: fight.id,
- hp: fight.hp,
- maxHp: fight.maxHp,
- name: fight.name,
- level: fight.level,
- fight_trigger: fight.fight_trigger
- };
-
- res.send(renderFightPreRound(data, true, location, location.city_id));
+ res.send(renderFightPreRound(fight, true, location, location.city_id));
});
app.post('/travel/step', authEndpoint, async (req: Request, res: Response) => {
const fight = await loadMonsterFromFight(req.player.id);
if(fight) {
// go to the fight screen
- const data: MonsterForFight = {
- id: fight.id,
- hp: fight.hp,
- maxHp: fight.maxHp,
- name: fight.name,
- level: fight.level,
- fight_trigger: fight.fight_trigger
- };
const location = await getMonsterLocation(fight.ref_id);
- res.send(renderPlayerBar(req.player) + renderFightPreRound(data, true, location, req.player.city_id));
+ res.send(renderPlayerBar(req.player) + renderFightPreRound(fight, true, location, req.player.city_id));
}
else {
const [city, locations, paths] = await Promise.all([
import { getEquippedItems, updateAp } from './inventory';
import { EquippedItemDetails } from '../shared/equipped';
import { EquipmentSlot } from '../shared/inventory';
-import { MonsterWithFaction, MonsterForFight } from '../shared/monsters';
+import { MonsterWithFaction, MonsterForFight, Fight } from '../shared/monsters';
import { getPlayerSkillsAsObject, updatePlayerSkills } from './skills';
import { SkillID, Skills } from '../shared/skills';
import { Request, Response } from 'express';
return Math.floor(finalExp);
}
-export async function fightRound(player: Player, monster: MonsterWithFaction, data: {action: 'attack' | 'cast' | 'flee', target: 'head' | 'body' | 'arms' | 'legs'}) {
+export async function fightRound(player: Player, monster: Fight, data: {action: 'attack' | 'cast' | 'flee', target: 'head' | 'body' | 'arms' | 'legs'}) {
const playerSkills = await getPlayerSkillsAsObject(player.id);
const roundData: FightRound = {
monster,
return {
id: monster.id,
name: monster.name,
- level: monster.minLevel,
+ minLevel: monster.minLevel,
+ maxLevel: monster.maxLevel,
hp: monster.hp,
maxHp: monster.maxHp,
fight_trigger: 'explore'
import { FightRound } from "shared/fight";
import { LocationWithCity } from "shared/map";
-import { MonsterForFight } from "../../shared/monsters";
+import { Fight, MonsterForFight } from "../../shared/monsters";
import { Button, ButtonWithBlock } from "./components/button";
export function renderRoundDetails(roundData: FightRound): string {
}
}
-export function renderFight(monster: MonsterForFight, results: string = '', displayFightActions: boolean = true, blockTime: number = 0) {
+export function renderFight(monster: Fight, results: string = '', displayFightActions: boolean = true, blockTime: number = 0) {
const hpPercent = Math.floor((monster.hp / monster.maxHp) * 100);
let html = `
return html;
}
-export function renderFightPreRound(monster: MonsterForFight, displayFightActions: boolean = true, location: LocationWithCity, closestTown: number) {
+export function renderFightPreRound(monster: Fight, displayFightActions: boolean = true, location: LocationWithCity, closestTown: number) {
const hpPercent = Math.floor((monster.hp / monster.maxHp) * 100);
let html = `