chore: some minor improvements to nemesis mode=s #2126
@ -170,6 +170,9 @@ export const nemesisController: RequestHandler = async (req, res) => {
 | 
			
		||||
        res.json({ LastEnc: inventory.Nemesis!.LastEnc });
 | 
			
		||||
    } else if ((req.query.mode as string) == "s") {
 | 
			
		||||
        const inventory = await getInventory(account._id.toString(), "Nemesis");
 | 
			
		||||
        if (inventory.Nemesis) {
 | 
			
		||||
            logger.warn(`account already has a nemesis but is requesting a new one; overwriting it`);
 | 
			
		||||
        }
 | 
			
		||||
        const body = getJSONfromString<INemesisStartRequest>(String(req.body));
 | 
			
		||||
        body.target.fp = BigInt(body.target.fp);
 | 
			
		||||
 | 
			
		||||
@ -185,13 +188,15 @@ export const nemesisController: RequestHandler = async (req, res) => {
 | 
			
		||||
            const weapons: readonly string[] = manifest.weapons;
 | 
			
		||||
            const initialWeaponIdx = new SRng(body.target.fp).randomInt(0, weapons.length - 1);
 | 
			
		||||
            weaponIdx = initialWeaponIdx;
 | 
			
		||||
            do {
 | 
			
		||||
                const weapon = weapons[weaponIdx];
 | 
			
		||||
                if (body.target.DisallowedWeapons.indexOf(weapon) == -1) {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                weaponIdx = (weaponIdx + 1) % weapons.length;
 | 
			
		||||
            } while (weaponIdx != initialWeaponIdx);
 | 
			
		||||
            if (body.target.DisallowedWeapons) {
 | 
			
		||||
                do {
 | 
			
		||||
                    const weapon = weapons[weaponIdx];
 | 
			
		||||
                    if (body.target.DisallowedWeapons.indexOf(weapon) == -1) {
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    weaponIdx = (weaponIdx + 1) % weapons.length;
 | 
			
		||||
                } while (weaponIdx != initialWeaponIdx);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        inventory.Nemesis = {
 | 
			
		||||
@ -212,10 +217,10 @@ export const nemesisController: RequestHandler = async (req, res) => {
 | 
			
		||||
            GuessHistory: [],
 | 
			
		||||
            Hints: [],
 | 
			
		||||
            HintProgress: 0,
 | 
			
		||||
            Weakened: body.target.Weakened,
 | 
			
		||||
            Weakened: false,
 | 
			
		||||
            PrevOwners: 0,
 | 
			
		||||
            HenchmenKilled: 0,
 | 
			
		||||
            SecondInCommand: body.target.SecondInCommand,
 | 
			
		||||
            SecondInCommand: false,
 | 
			
		||||
            MissionCount: 0,
 | 
			
		||||
            LastEnc: 0
 | 
			
		||||
        };
 | 
			
		||||
@ -276,7 +281,7 @@ interface INemesisStartRequest {
 | 
			
		||||
        KillingSuit: string;
 | 
			
		||||
        killingDamageType: number;
 | 
			
		||||
        ShoulderHelmet: string;
 | 
			
		||||
        DisallowedWeapons: string[];
 | 
			
		||||
        DisallowedWeapons?: string[];
 | 
			
		||||
        WeaponIdx: number;
 | 
			
		||||
        AgentIdx: number;
 | 
			
		||||
        BirthNode: string;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user