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

Replace the raw minigame and boss values with enums #288

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/common/GameModeSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ ShyGuyTagGameModeSettings::ShyGuyTagGameModeSettings()
{}

BossGameModeSettings::BossGameModeSettings()
: bosstype(0) //Default to hammer boss
: bosstype(Boss::Hammer) //Default to hammer boss
, difficulty(2) //Medium difficulty
, hitpoints(5) //5 hits to kill
{}
3 changes: 2 additions & 1 deletion src/common/GameModeSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define GAMEMODESETTINGS_H

#include "GlobalConstants.h"
#include "MatchTypes.h"

struct ClassicGameModeSettings {
short style; //on kill, either respawn the player or shield them and let them keep playing
Expand Down Expand Up @@ -175,7 +176,7 @@ struct ShyGuyTagGameModeSettings {
};

struct BossGameModeSettings {
short bosstype; //What type of boss battle it is
Boss bosstype; //What type of boss battle it is
short difficulty; //How hard the boss is to defeat
short hitpoints; //How much life the boss has

Expand Down
4 changes: 2 additions & 2 deletions src/common/GameValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ void CGameValues::init()
spawnstyle = SpawnStyle::Swirl;
tournamentgames = 2;
tournamentwinner = -1;
selectedminigame = 0;
matchtype = MatchType::SingleGame;
selectedminigame = Minigame::PipeCoin;
matchtype = MatchType::SingleGame;
tourindex = 0;
tourstopcurrent = 0;
tourstoptotal = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/common/GameValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class CGameValues : public CGameConfig
short tournamentcontrolteam; //The team ID that currently has control
short tournamentnextcontrol; //For round robin control style

short selectedminigame;
Minigame selectedminigame;

short tourindex;
short tourstopcurrent;
Expand Down
18 changes: 17 additions & 1 deletion src/common/MatchTypes.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

enum class MatchType: unsigned char {
enum class MatchType : unsigned char {
SingleGame,
Tournament,
Tour,
Expand All @@ -9,3 +9,19 @@ enum class MatchType: unsigned char {
QuickGame,
NetGame,
};


enum class Minigame : unsigned char {
PipeCoin,
HammerBoss,
BombBoss,
FireBoss,
Boxes,
};


enum class Boss : unsigned char {
Hammer,
Bomb,
Fire,
};
2 changes: 2 additions & 0 deletions src/common/ui/MI_SelectField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ template class MI_SelectField<bool>;
template class MI_SelectField<short>;

#include "MatchTypes.h"
template class MI_SelectField<Boss>;
template class MI_SelectField<MatchType>;
template class MI_SelectField<Minigame>;

#include "EyecandyStyles.h"
template class MI_SelectField<AwardStyle>;
Expand Down
70 changes: 45 additions & 25 deletions src/smw/GSMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,23 +690,39 @@ void MenuState::update()

if (MatchType::MiniGame == game_values.matchtype) {
printf(" Match type: Minigame\n");
short iMiniGameType = mMatchSelectionMenu->GetMinigameID();

if (iMiniGameType == 0) { //Pipe minigame
pipegamemode->goal = 50;
game_values.gamemode = pipegamemode;
} else if (iMiniGameType >= 1 && iMiniGameType <= 3) { //3 types of boss minigames
game_values.gamemodemenusettings.boss.bosstype = iMiniGameType - 1;
game_values.gamemodemenusettings.boss.difficulty = 2;
game_values.gamemodemenusettings.boss.hitpoints = 5;

bossgamemode->goal = 5;
game_values.gamemode = bossgamemode;
} else if (iMiniGameType == 4) { //boxes minigame
boxesgamemode->goal = 10;
game_values.gamemode = boxesgamemode;
const Minigame minigame = mMatchSelectionMenu->GetMinigame();
switch (minigame) {
case Minigame::PipeCoin:
pipegamemode->goal = 50;
game_values.gamemode = pipegamemode;
break;
case Minigame::HammerBoss:
case Minigame::BombBoss:
case Minigame::FireBoss:
game_values.gamemodemenusettings.boss.difficulty = 2;
game_values.gamemodemenusettings.boss.hitpoints = 5;

bossgamemode->goal = 5;
game_values.gamemode = bossgamemode;
break;
case Minigame::Boxes:
boxesgamemode->goal = 10;
game_values.gamemode = boxesgamemode;
break;
}
switch (minigame) {
case Minigame::HammerBoss:
game_values.gamemodemenusettings.boss.bosstype = Boss::Hammer;
break;
case Minigame::BombBoss:
game_values.gamemodemenusettings.boss.bosstype = Boss::Bomb;
break;
case Minigame::FireBoss:
game_values.gamemodemenusettings.boss.bosstype = Boss::Fire;
break;
default:
break;
}

StartGame();
} else if (MatchType::QuickGame == game_values.matchtype) {
printf(" Match type: Quick game\n");
Expand Down Expand Up @@ -1350,15 +1366,19 @@ void MenuState::update()
}
} else if (game_values.gamemode->gamemode == game_mode_boss_minigame) {
if (!fMiniGameMapFound) {
short iBossType = game_values.gamemodesettings.boss.bosstype;
bossgamemode->SetBossType(iBossType);
if (iBossType == 0)
g_map->loadMap(convertPath("maps/special/two52_special_hammerboss_minigame.map"), read_type_full);
else if (iBossType == 1)
g_map->loadMap(convertPath("maps/special/two52_special_bombboss_minigame.map"), read_type_full);
else if (iBossType == 2)
g_map->loadMap(convertPath("maps/special/two52_special_fireboss_minigame.map"), read_type_full);

Boss bossType = game_values.gamemodesettings.boss.bosstype;
bossgamemode->SetBossType(bossType);
switch (bossType) {
case Boss::Hammer:
g_map->loadMap(convertPath("maps/special/two52_special_hammerboss_minigame.map"), read_type_full);
break;
case Boss::Bomb:
g_map->loadMap(convertPath("maps/special/two52_special_bombboss_minigame.map"), read_type_full);
break;
case Boss::Fire:
g_map->loadMap(convertPath("maps/special/two52_special_fireboss_minigame.map"), read_type_full);
break;
}
sShortMapName = "minigameboss";
}
} else if (game_values.gamemode->gamemode == game_mode_boxes_minigame) {
Expand Down
28 changes: 16 additions & 12 deletions src/smw/gamemodes/MiniBoss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ CGM_Boss_MiniGame::CGM_Boss_MiniGame() : CGameMode()
{
gamemode = game_mode_boss_minigame;
SetupModeStrings("Boss", "Lives", 5);
iBossType = 0;
}

void CGM_Boss_MiniGame::init()
Expand All @@ -39,7 +38,7 @@ void CGM_Boss_MiniGame::init()
for (short iScore = 0; iScore < score_cnt; iScore++)
score[iScore]->SetScore(goal);

objectcontainer[0].add(new MO_SledgeBrother(&rm->spr_sledgebrothers, (iBossType == 0 ? 256 : (iBossType == 1 ? 256 : smw->ScreenWidth/2)), iBossType));
objectcontainer[0].add(new MO_SledgeBrother(&rm->spr_sledgebrothers, (iBossType == Boss::Hammer ? 256 : (iBossType == Boss::Bomb ? 256 : smw->ScreenWidth/2)), iBossType));
}


Expand All @@ -61,15 +60,15 @@ void CGM_Boss_MiniGame::think()
if (gameover) {
displayplayertext();
} else {
if (iBossType == 0) {
if (iBossType == Boss::Hammer) {
//Randomly spawn koopas
if (--enemytimer <= 0) {
objectcontainer[0].add(new MO_Koopa(&rm->spr_koopa, RANDOM_BOOL(), false, false, true));
enemytimer = (short)RANDOM_INT(120) + 120; //Spawn koopas slowly
}
} else if (iBossType == 1) {
} else if (iBossType == Boss::Bomb) {

} else if (iBossType == 2) {
} else if (iBossType == Boss::Fire) {
//Only create podobos if the difficulty is moderate or greater
if (--enemytimer <= 0 && game_values.gamemodesettings.boss.difficulty >= 2) {
objectcontainer[2].add(new MO_Podobo(&rm->spr_podobo, (short)RANDOM_INT(smw->ScreenWidth * 0.95f), smw->ScreenHeight, -(float(RANDOM_INT(9)) / 2.0f) - 9.0f, -1, -1, -1, false));
Expand All @@ -93,12 +92,17 @@ void CGM_Boss_MiniGame::draw_foreground()
if (winningteam == -1) {
rm->game_font_large.drawCentered(smw->ScreenWidth/2, 96, "You Failed To Defeat");

if (iBossType == 0)
rm->game_font_large.drawCentered(smw->ScreenWidth/2, 118, "The Mighty Sledge Brother");
else if (iBossType == 1)
rm->game_font_large.drawCentered(smw->ScreenWidth/2, 118, "The Mighty Bomb Brother");
else if (iBossType == 2)
rm->game_font_large.drawCentered(smw->ScreenWidth/2, 118, "The Mighty Flame Brother");
switch (iBossType) {
case Boss::Hammer:
rm->game_font_large.drawCentered(smw->ScreenWidth/2, 118, "The Mighty Sledge Brother");
break;
case Boss::Bomb:
rm->game_font_large.drawCentered(smw->ScreenWidth/2, 118, "The Mighty Bomb Brother");
break;
case Boss::Fire:
rm->game_font_large.drawCentered(smw->ScreenWidth/2, 118, "The Mighty Flame Brother");
break;
}
}
}
}
Expand Down Expand Up @@ -196,7 +200,7 @@ bool CGM_Boss_MiniGame::SetWinner(CPlayer * player)
return true;
}

void CGM_Boss_MiniGame::SetBossType(short bosstype)
void CGM_Boss_MiniGame::SetBossType(Boss bosstype)
{
iBossType = bosstype;
}
7 changes: 4 additions & 3 deletions src/smw/gamemodes/MiniBoss.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "GameMode.h"
#include "MatchTypes.h"


//Special mode where players try to kill a boss
Expand All @@ -21,8 +22,8 @@ class CGM_Boss_MiniGame : public CGameMode
char *getMenuString(char *buffer64);

bool SetWinner(CPlayer * player);
void SetBossType(short bosstype);
short GetBossType() {
void SetBossType(Boss bosstype);
Boss GetBossType() const {
return iBossType;
}

Expand All @@ -33,5 +34,5 @@ class CGM_Boss_MiniGame : public CGameMode
private:

short enemytimer, poweruptimer;
short iBossType;
Boss iBossType = Boss::Hammer;
};
16 changes: 8 additions & 8 deletions src/smw/menu/MatchSelectionMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ UI_MatchSelectionMenu::UI_MatchSelectionMenu()
miWorldField->setItemChangedCode(MENU_CODE_WORLD_MAP_CHANGED);
miWorldField->Show(false);

miMinigameField = new MI_SelectField<short>(&rm->spr_selectfield, 130, 380, "Game", 380, 100);
miMinigameField->add("Pipe Coin Game", 0);
miMinigameField->add("Hammer Boss Game", 1);
miMinigameField->add("Bomb Boss Game", 2);
miMinigameField->add("Fire Boss Game", 3);
miMinigameField->add("Boxes Game", 4);
miMinigameField = new MI_SelectField<Minigame>(&rm->spr_selectfield, 130, 380, "Game", 380, 100);
miMinigameField->add("Pipe Coin Game", Minigame::PipeCoin);
miMinigameField->add("Hammer Boss Game", Minigame::HammerBoss);
miMinigameField->add("Bomb Boss Game", Minigame::BombBoss);
miMinigameField->add("Fire Boss Game", Minigame::FireBoss);
miMinigameField->add("Boxes Game", Minigame::Boxes);
miMinigameField->setOutputPtr(&game_values.selectedminigame);
miMinigameField->setCurrentValue(game_values.selectedminigame);
miMinigameField->Show(false);
Expand Down Expand Up @@ -138,12 +138,12 @@ void UI_MatchSelectionMenu::ActivateMinigameField()
miMatchSelectionDisplayImage->SetImage(0, 240 * static_cast<int>(game_values.matchtype), 320, 240);
}

short UI_MatchSelectionMenu::GetMinigameID()
Minigame UI_MatchSelectionMenu::GetMinigame() const
{
return miMinigameField->currentValue();
}

MatchType UI_MatchSelectionMenu::GetSelectedMatchType()
MatchType UI_MatchSelectionMenu::GetSelectedMatchType() const
{
return miMatchSelectionField->currentValue();
}
6 changes: 3 additions & 3 deletions src/smw/menu/MatchSelectionMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class UI_MatchSelectionMenu : public UI_Menu {
void SelectionChanged();
void WorldMapChanged();
void ActivateMinigameField();
short GetMinigameID();
MatchType GetSelectedMatchType();
Minigame GetMinigame() const;
MatchType GetSelectedMatchType() const;

private:
MI_Image* miMatchSelectionDisplayImage;
Expand All @@ -27,7 +27,7 @@ class UI_MatchSelectionMenu : public UI_Menu {
MI_SelectField<short>* miTournamentField;
MI_SelectField<short>* miTourField;
MI_SelectField<short>* miWorldField;
MI_SelectField<short>* miMinigameField;
MI_SelectField<Minigame>* miMinigameField;
MI_WorldPreviewDisplay* miWorldPreviewDisplay;

MI_Button* miMatchSelectionStartButton;
Expand Down
8 changes: 4 additions & 4 deletions src/smw/menu/ModeOptionsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,10 +1330,10 @@ UI_ModeOptionsMenu::UI_ModeOptionsMenu()
// Boss Mode Settings
//***********************

miBossModeTypeField = new MI_SelectField<short>(&rm->spr_selectfield, 120, 180, "Type", 400, 180);
miBossModeTypeField->add("Hammer", 0);
miBossModeTypeField->add("Bomb", 1);
miBossModeTypeField->add("Fire", 2);
miBossModeTypeField = new MI_SelectField<Boss>(&rm->spr_selectfield, 120, 180, "Type", 400, 180);
miBossModeTypeField->add("Hammer", Boss::Hammer);
miBossModeTypeField->add("Bomb", Boss::Bomb);
miBossModeTypeField->add("Fire", Boss::Fire);
miBossModeTypeField->setOutputPtr(&game_values.gamemodemenusettings.boss.bosstype);
miBossModeTypeField->setCurrentValue(game_values.gamemodemenusettings.boss.bosstype);

Expand Down
3 changes: 2 additions & 1 deletion src/smw/menu/ModeOptionsMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class MI_PowerupSlider;
class MI_SliderField;
class MI_Text;
template<typename T> class MI_SelectField;
enum class Boss : unsigned char;


class UI_ModeOptionsMenu : public UI_Menu {
Expand Down Expand Up @@ -250,7 +251,7 @@ class UI_ModeOptionsMenu : public UI_Menu {
MI_Text* miShyGuyTagModeHeaderText;

// Boss
MI_SelectField<short>* miBossModeTypeField;
MI_SelectField<Boss>* miBossModeTypeField;
MI_SelectField<short>* miBossModeDifficultyField;
MI_SelectField<short>* miBossModeHitPointsField;
MI_Button* miBossModeBackButton;
Expand Down
4 changes: 2 additions & 2 deletions src/smw/objectgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4656,10 +4656,10 @@ short g_iSledgeBrotherWaitTime[3][5][2] = {
{{30,50},{25,45},{20,40},{15,30},{10,20}}
};

MO_SledgeBrother::MO_SledgeBrother(gfxSprite *nspr, short platformY, short type) :
MO_SledgeBrother::MO_SledgeBrother(gfxSprite *nspr, short platformY, Boss type) :
IO_MovingObject(nspr, 0, 0, 8, 0, 32, 56, 8, 8)
{
iType = type;
iType = static_cast<short>(type); // FIXME
state = 1;
iActionState = 0;
location = 2;
Expand Down
3 changes: 2 additions & 1 deletion src/smw/objects/moving/SledgeBrother.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once

#include "MatchTypes.h"
#include "MovingObject.h"


class MO_SledgeBrother : public IO_MovingObject
{
public:
MO_SledgeBrother(gfxSprite *nspr, short platformY, short type);
MO_SledgeBrother(gfxSprite *nspr, short platformY, Boss type);
virtual ~MO_SledgeBrother(){};

void draw() override;
Expand Down
Loading