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] Flip Stats Challenge #5087

Open
wants to merge 24 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bcb891d
Implement Flip Stat Challange
mt3 Jan 4, 2025
464c931
Add Achivement
mt3 Jan 5, 2025
757a26f
Remove Debug Code
mt3 Jan 5, 2025
c64c853
Update challenge code to block other challenges. TODO: Helper functio…
ismywb Jan 5, 2025
c6e360e
Add Achievment Image
ismywb Jan 5, 2025
6e332e4
Fix Ribbon not being granted
ismywb Jan 5, 2025
1734854
Update src/game-mode.ts
Scoooom Jan 6, 2025
fae46ec
Update src/data/challenge.ts
Scoooom Jan 6, 2025
824bca7
Update src/data/challenge.ts
Scoooom Jan 6, 2025
5422dd7
Update src/data/challenge.ts
Scoooom Jan 6, 2025
e9faa14
Update src/data/challenge.ts
Scoooom Jan 6, 2025
927b465
Add FLIP_STAT to enum ChallengeType
ismywb Jan 6, 2025
c67c992
Fix comment for FlipStatChallenge
ismywb Jan 7, 2025
6d36ccf
Update src/field/pokemon.ts
Scoooom Jan 7, 2025
6af2930
Add applyFlipStat override to Challenge Class, and add override insid…
ismywb Jan 7, 2025
6049cbd
Merge branch 'flip_stats_challange' of github.com:Scoooom/pokerogue i…
ismywb Jan 7, 2025
d71c799
Update src/game-mode.ts
Scoooom Jan 7, 2025
172a890
Add ChallengeType.FLIP_STAT case to export function applyChallenges (…
ismywb Jan 7, 2025
13ec567
Merge branch 'flip_stats_challange' of github.com:Scoooom/pokerogue i…
ismywb Jan 7, 2025
8343719
Properly block other challange achviements
ismywb Jan 7, 2025
c7dcaf1
Change the way achivements are blocked by challenge modes to a more f…
ismywb Jan 7, 2025
20f750a
Update src/system/achv.ts
Scoooom Jan 7, 2025
d1cb433
Adjust the image for Flip Stat, and add an additional achivement for …
ismywb Jan 9, 2025
dc482ea
Fix FLIP_INVERSE achivement to check ALL challanges are met, not SOME
ismywb Jan 9, 2025
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
Binary file added public/images/items/flipstat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions src/data/challenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export enum ChallengeType {
* Modifies what weight AI pokemon have when generating movesets. UNIMPLEMENTED.
*/
MOVE_WEIGHT,
/**
* Modifies what the pokemon stats for Flip Stat Mode.
*/
FLIP_STAT,

}

/**
Expand Down Expand Up @@ -401,6 +406,16 @@ export abstract class Challenge {
applyMoveWeight(pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.IntegerHolder): boolean {
return false;
}

/**
* An apply function for FlipStats. Derived classes should alter this.
* @param pokemon {@link Pokemon} What pokemon would learn the move.
* @param baseStats What are the stats to flip.
* @returns {@link boolean} Whether this function did anything.
*/
applyFlipStat(pokemon: Pokemon, baseStats: number[]) {
return false;
}
}

type ChallengeCondition = (data: GameData) => boolean;
Expand Down Expand Up @@ -701,6 +716,33 @@ export class InverseBattleChallenge extends Challenge {
}
}

/**
* Implements a flip stat challenge.
*/
export class FlipStatChallenge extends Challenge {
constructor() {
super(Challenges.FLIP_STAT, 1);
}

override applyFlipStat(pokemon: Pokemon, baseStats: number[]) {
const origStats = Utils.deepCopy(baseStats);
baseStats[0] = origStats[5];
baseStats[1] = origStats[4];
baseStats[2] = origStats[3];
baseStats[3] = origStats[2];
baseStats[4] = origStats[1];
baseStats[5] = origStats[0];
return true;
}

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

/**
* Lowers the amount of starter points available.
*/
Expand Down Expand Up @@ -886,6 +928,9 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType
* @returns True if any challenge was successfully applied.
*/
export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.MOVE_WEIGHT, pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, weight: Utils.IntegerHolder): boolean;

export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.FLIP_STAT, pokemon: Pokemon, baseStats: number[]): boolean;
Scoooom marked this conversation as resolved.
Show resolved Hide resolved

export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType, ...args: any[]): boolean {
Scoooom marked this conversation as resolved.
Show resolved Hide resolved
let ret = false;
gameMode.challenges.forEach(c => {
Expand Down Expand Up @@ -930,6 +975,9 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType
case ChallengeType.MOVE_WEIGHT:
ret ||= c.applyMoveWeight(args[0], args[1], args[2], args[3]);
break;
case ChallengeType.FLIP_STAT:
ret ||= c.applyFlipStat(args[0], args[1]);
break;
}
}
});
Expand All @@ -955,6 +1003,8 @@ export function copyChallenge(source: Challenge | any): Challenge {
return FreshStartChallenge.loadChallenge(source);
case Challenges.INVERSE_BATTLE:
return InverseBattleChallenge.loadChallenge(source);
case Challenges.FLIP_STAT:
return FlipStatChallenge.loadChallenge(source);
}
throw new Error("Unknown challenge copied");
}
Expand All @@ -967,5 +1017,6 @@ export function initChallenges() {
new SingleTypeChallenge(),
new FreshStartChallenge(),
new InverseBattleChallenge(),
new FlipStatChallenge()
);
}
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,
FLIP_STAT,
}
1 change: 1 addition & 0 deletions src/field/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {

calculateBaseStats(): number[] {
const baseStats = this.getSpeciesForm(true).baseStats.slice(0);
applyChallenges(this.scene.gameMode, ChallengeType.FLIP_STAT, this, baseStats);
// Shuckle Juice
this.scene.applyModifiers(PokemonBaseStatTotalModifier, this.isPlayer(), this, baseStats);
// Old Gateau
Expand Down
Loading
Loading