Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Challenge] Add Trick room challenge #4343

Open
wants to merge 29 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dc36bcd
add initial commit for trick room
KimJeongSun Sep 20, 2024
d334a55
add english translation
KimJeongSun Sep 20, 2024
6fc0806
update variable name and comment
KimJeongSun Sep 20, 2024
f172003
Merge branch 'beta' into trick-room-challenge
flx-sta Sep 20, 2024
2044a99
update achievement for challenge
KimJeongSun Sep 20, 2024
b6994e9
Update src/data/challenge.ts
KimJeongSun Sep 20, 2024
241b585
Update src/data/challenge.ts
KimJeongSun Sep 20, 2024
599b197
Update src/data/challenge.ts
KimJeongSun Sep 20, 2024
77df8f5
apply inverted speed IV in trick room challenge
KimJeongSun Sep 20, 2024
73411c7
update requested changes
KimJeongSun Sep 20, 2024
6f3e97d
update requested change 2
KimJeongSun Sep 20, 2024
d3cd4f4
Add Room Service item sprite
Madmadness65 Sep 21, 2024
340e1e0
update order optimization
KimJeongSun Sep 21, 2024
b7aa0ed
remove hacky invert speed IV code
KimJeongSun Sep 21, 2024
7ef2dcc
Update src/data/challenge.ts
KimJeongSun Sep 21, 2024
3801395
Update src/phases/turn-start-phase.ts
KimJeongSun Sep 21, 2024
247bd9d
Merge branch 'beta' into trick-room-challenge
Adri1 Sep 22, 2024
21a9e28
Merge branch 'beta' into trick-room-challenge
KimJeongSun Sep 26, 2024
a75f0d2
Merge branch 'beta' into trick-room-challenge
KimJeongSun Sep 26, 2024
37e9fa8
revert optimization. it will be on other PR
KimJeongSun Sep 27, 2024
869535a
update challenge type to ARENA_TAG from TRICK_ROOM
KimJeongSun Sep 27, 2024
f0b561d
Merge branch 'beta' into trick-room-challenge
KimJeongSun Sep 27, 2024
680578a
Merge branch 'beta' into trick-room-challenge
Adri1 Sep 28, 2024
a929975
update requested changes from xavion
KimJeongSun Oct 1, 2024
9b4b074
Merge branch 'beta' into trick-room-challenge
KimJeongSun Oct 27, 2024
a2f26bb
update items.json,png, room_service.png
KimJeongSun Oct 27, 2024
1be99c2
reorder trickroom achivement
KimJeongSun Oct 27, 2024
1badbe4
Merge branch 'beta' into trick-room-challenge
Adri1 Nov 2, 2024
3dd6647
Merge remote-tracking branch 'upstream/beta' into trick-room-challenge
KimJeongSun Nov 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,987 changes: 2,004 additions & 1,983 deletions public/images/items.json

Large diffs are not rendered by default.

Binary file modified public/images/items.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions src/data/challenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export enum ChallengeType {
* @see {@linkcode Challenge.applyTypeEffectiveness}
*/
TYPE_EFFECTIVENESS,
/**
* Challenge that enables Trick Room in a run
*/
TRICK_ROOM,
KimJeongSun marked this conversation as resolved.
Show resolved Hide resolved
KimJeongSun marked this conversation as resolved.
Show resolved Hide resolved
/**
* Modifies what level the AI pokemon are. UNIMPLEMENTED.
*/
Expand Down Expand Up @@ -340,6 +344,15 @@ export abstract class Challenge {
return false;
}

/**
* An apply function for TRICK_ROOM challenges. Derived classes should alter this.
* @param isTrickRoom {@link Utils.BooleanHolder} Whether the battle is under the effect of Trick Room.
* @returns `true` if this function did anything.
*/
applyTrickRoom(isTrickRoom: Utils.BooleanHolder): boolean {
KimJeongSun marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

/**
* An apply function for AI_LEVEL challenges. Derived classes should alter this.
* @param level {@link Utils.IntegerHolder} The generated level.
Expand Down Expand Up @@ -707,6 +720,35 @@ export class InverseBattleChallenge extends Challenge {
}
}

/**
* Challenge that enables Trick Room in a run
*/
export class TrickRoomChallenge extends Challenge {
constructor() {
super(Challenges.TRICK_ROOM, 1);
}

static loadChallenge(source: TrickRoomChallenge | any): TrickRoomChallenge {
const newChallenge = new TrickRoomChallenge();
newChallenge.value = source.value;
newChallenge.severity = source.severity;
return newChallenge;
}

override getDifficulty(): number {
return 0;
}

KimJeongSun marked this conversation as resolved.
Show resolved Hide resolved
applyTrickRoom(isTrickRoom: Utils.BooleanHolder): boolean {
KimJeongSun marked this conversation as resolved.
Show resolved Hide resolved
if (!isTrickRoom.value) {
isTrickRoom.value = true;
} else {
isTrickRoom.value = false;
}
KimJeongSun marked this conversation as resolved.
Show resolved Hide resolved
return true;
}
}

/**
* Lowers the amount of starter points available.
*/
Expand Down Expand Up @@ -834,6 +876,14 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType
* @returns True if any challenge was successfully applied.
*/
export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.TYPE_EFFECTIVENESS, effectiveness: Utils.NumberHolder): boolean;
/**
* Apply all challenges that modify Trick Room.
* @param gameMode The current {@linkcode GameMode}
* @param challengeType {@linkcode ChallengeType.TRICK_ROOM}
* @param isTrickRoom {@linkcode Utils.BooleanHolder} Whether the battle is under the effect of Trick Room.
* @returns `true` if any challenge was successfully applied.
*/
export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.TRICK_ROOM, isTrickRoom: Utils.BooleanHolder): boolean;
/**
* Apply all challenges that modify what level AI are.
* @param gameMode {@link GameMode} The current gameMode
Expand Down Expand Up @@ -918,6 +968,9 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType
case ChallengeType.TYPE_EFFECTIVENESS:
ret ||= c.applyTypeEffectiveness(args[0]);
break;
case ChallengeType.TRICK_ROOM:
ret ||= c.applyTrickRoom(args[0]);
break;
case ChallengeType.AI_LEVEL:
ret ||= c.applyLevelChange(args[0], args[1], args[2], args[3]);
break;
Expand Down Expand Up @@ -961,6 +1014,8 @@ export function copyChallenge(source: Challenge | any): Challenge {
return FreshStartChallenge.loadChallenge(source);
case Challenges.INVERSE_BATTLE:
return InverseBattleChallenge.loadChallenge(source);
case Challenges.TRICK_ROOM:
return TrickRoomChallenge.loadChallenge(source);
}
throw new Error("Unknown challenge copied");
}
Expand All @@ -973,5 +1028,6 @@ export function initChallenges() {
new SingleTypeChallenge(),
new FreshStartChallenge(),
new InverseBattleChallenge(),
new TrickRoomChallenge(),
);
}
1 change: 1 addition & 0 deletions src/enums/challenges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export enum Challenges {
LOWER_STARTER_POINTS,
FRESH_START,
INVERSE_BATTLE,
TRICK_ROOM,
}
4 changes: 4 additions & 0 deletions src/locales/en/achv.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@
"name": "Mirror rorriM",
"description": "Complete the Inverse Battle challenge.\n.egnellahc elttaB esrevnI eht etelpmoC"
},
"TRICK_ROOM": {
"name": "You're Too Fast!",
"description": "Complete the Trick Room challenge."
},
"BREEDERS_IN_SPACE": {
"name": "Breeders in Space!",
"description": "Beat the Expert Pokémon Breeder in the Space Biome."
Expand Down
7 changes: 7 additions & 0 deletions src/locales/en/challenges.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,12 @@
"desc": "Type matchups are reversed and no type is immune to any other type.\nDisables other challenges' achievements.",
"value.0": "Off",
"value.1": "On"
},
"trickRoom": {
"name": "Trick Room",
"shortName": "Trick Room",
"desc": "All battles are under the effect of Trick Room, where slower Pokémon move sooner and faster Pokémon move later.\nDisables other challenges' achievements.",
"value.0": "Off",
"value.1": "On"
}
}
2 changes: 2 additions & 0 deletions src/phases/turn-start-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { TurnEndPhase } from "./turn-end-phase";
import { WeatherEffectPhase } from "./weather-effect-phase";
import { BattlerIndex } from "#app/battle";
import { TrickRoomTag } from "#app/data/arena-tag";
import { applyChallenges, ChallengeType } from "#app/data/challenge";

export class TurnStartPhase extends FieldPhase {
constructor(scene: BattleScene) {
Expand Down Expand Up @@ -52,6 +53,7 @@ export class TurnStartPhase extends FieldPhase {
// Next, a check for Trick Room is applied. If Trick Room is present, the order is reversed.
const speedReversed = new Utils.BooleanHolder(false);
this.scene.arena.applyTags(TrickRoomTag, speedReversed);
applyChallenges(this.scene.gameMode, ChallengeType.TRICK_ROOM, speedReversed);
KimJeongSun marked this conversation as resolved.
Show resolved Hide resolved

if (speedReversed.value) {
orderedTargets = orderedTargets.reverse();
Expand Down
Loading
Loading