mName is char* I will do some research on comparing strings.
Here is the code with your suggested updates:
#include "Monster.h"
//Monster(char* mName,bool inCombat, int initRoll,int hp, int initMod)
//.roll() updates initRoll with D20+initMod
//.engage() move to combat
//.kill() remove from combat
//----------------------------------------------------------------------------------------------
//Variables
const int TOME_LENGTH = 12; //the length of the master tome of players and monsters
Monster tome[TOME_LENGTH] = {
{"Thio Ki",1,25,4, false, "PC Human Wizard"},
{"Zenwan",1,27,2, false, "PC Halfling Rogue"},
{"Balkas",1,33,4, false, "PC Elf Monk"},
{"Fire Wolf",1,7,2, true, "AC=13 Flame Bite Melee +4 2d4+1 one fire"},
{"Fire Wolf",1,7,2, true, "AC=13 Flame Bite Melee +4 2d4+1 one fire"},
{"Fire Sprite",1,7,0, true, "AC=9 Melee Bite +4 2d4 one fire"},
{"Son of Ignis",1,10,1, true, "AC=11 Spell Caster Melee +3 1d4"},
{"Son of Ignis",1,10,1, true, "AC=11 Spell Caster Melee +3 1d4"},
{"Son of Ignis",1,10,1, true, "AC=11 Spell Caster Melee +3 1d4"},
{"Son of Ignis",1,10,1, true, "AC=11 Spell Caster Melee +3 1d4"},
{"Son of Ignis",1,10,1, true, "AC=11 Spell Caster Melee +3 1d4"},
{"Aiden",1,14,1, true, "AC=13 Spell Caster Melee +3 1d4"}
};
void setup() {
Serial.begin(9600);
Serial.println("Hello");
multiMonster();
for(byte i = 0; i < TOME_LENGTH; i++){
Serial.println(tome[i].mName);
}
}
void loop() {
}
//-------------------------------------------------------------------
void multiMonster(){
for(byte active = 0; active < TOME_LENGTH; active++){
byte monsterMatch[TOME_LENGTH]; //make a place to hold the matching indexes
monsterMatch[0] = active; //add the current monster to monsterMatch
byte matchCounter = 1; //set the counter to one, this should increment everytime there is another matching name found
for(byte compare = 0; compare < TOME_LENGTH; compare ++){
if(tome[active].mName == tome[compare].mName && active != compare){ //if the mName of the active monster matched the one we're comparing it to and they are not the same monster
monsterMatch[matchCounter] = compare; //add their index to the monsterMatch array
matchCounter ++; //increment the matchCounter for the next monster (if needed)
}
}
if (matchCounter > 1){ //if a second monster was added to the list
for(byte m = 0; m < matchCounter; m ++){ //append 1 to the first monster, 2 to the second monster, 3 to the third monster)
char monsterBuffer[4];
sprintf (monsterBuffer, " %d", m);
tome[monsterMatch[m]].mName = strcat(tome[monsterMatch[m]].mName, monsterBuffer);
}
}
}
}