Skip to content

Commit

Permalink
Added Fudge Rolls to DM UI
Browse files Browse the repository at this point in the history
  • Loading branch information
DMD authored and DMD committed Sep 11, 2017
1 parent 4a269d4 commit b7b434a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
22 changes: 22 additions & 0 deletions TemplePlus/dungeon_master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ void DungeonMaster::Render() {
ImGui::TreePop();
}

// Roll Fudger
if (ImGui::TreeNodeEx("Fudge Rolls", ImGuiTreeNodeFlags_CollapsingHeader)) {

RenderFudgeRolls();
ImGui::TreePop();
}

// Monster Tree
if (ImGui::TreeNodeEx("Monsters", ImGuiTreeNodeFlags_CollapsingHeader)) {

Expand Down Expand Up @@ -1255,6 +1262,17 @@ void DungeonMaster::RenderVsParty(){



}

void DungeonMaster::RenderFudgeRolls(){

ImGui::Text("Force dice roll results:");
ImGui::RadioButton("Normal", &mForceRollType, 0); ImGui::SameLine();
ImGui::RadioButton("Min", &mForceRollType, 1); ImGui::SameLine();
ImGui::RadioButton("Avg", &mForceRollType, 2); ImGui::SameLine();
ImGui::RadioButton("Max", &mForceRollType, 3);


}

void DungeonMaster::SetObjEditor(objHndl handle){
Expand Down Expand Up @@ -1369,6 +1387,10 @@ void DungeonMaster::SetIsHandlingMsg(bool b){
isHandlingMsg = b;
}

int DungeonMaster::GetDiceRollForcing(){
return mForceRollType;
}

bool DungeonMaster::IsMoused(){
return isMoused;
}
Expand Down
4 changes: 4 additions & 0 deletions TemplePlus/dungeon_master.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ class DungeonMaster
bool IsHandlingMsg();
void SetIsHandlingMsg(bool b);;

int GetDiceRollForcing();

void Render();
void RenderDmButton();
void RenderMaps();
void RenderEditedObj();
void RenderVsParty();
void RenderFudgeRolls();

bool HandleMsg(const TigMsg & msg);
bool HandleSpawning(const TigMsg & msg);
Expand Down Expand Up @@ -88,6 +91,7 @@ class DungeonMaster
// bool mIsActive = true;
bool mJustOpened = false;

int mForceRollType; // 0 - normal, 1 - rolls 1s, 2 - roll 10s, 3 - rolls 20s

void RenderMonster(Record& record);
void RenderMonsterFilter();
Expand Down
24 changes: 22 additions & 2 deletions TemplePlus/temple_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "config/config.h"
#include "util/fixes.h"
#include "rng.h"
#include <dungeon_master.h>

TempleFuncs templeFuncs;

Expand All @@ -25,9 +26,28 @@ class TempleFuncReplacements : public TempleFix

int32_t TempleFuncs::diceRoll(uint32_t dieNum, uint32_t dieType, int32_t dieBonus)
{
auto dmFudge = dmSys.GetDiceRollForcing();
int32_t result = dieBonus;
for (uint32_t i = 0; i < dieNum; i++)
{

switch (dmFudge){
case 0:
for (uint32_t i = 0; i < dieNum; i++) {
result += rngSys.GetInt(1, dieType);
}
return result;
case 1:
result += 1 * dieNum;
return result;
case 2:
result += (int)ceil( ( (1.0 + dieType) * dieNum) / 2); // average, rounded up for even dice
return result;
case 3:
result += dieNum * dieType;
return result;
default:
break;
}
for (uint32_t i = 0; i < dieNum; i++){
result += rngSys.GetInt(1, dieType);
}
return result;
Expand Down

0 comments on commit b7b434a

Please sign in to comment.