public OSRICAttributeModel(RPGCharacterModel _cm, JSONObject _jo) { cm = _cm; CharacterModifiers = new OSRICModifierCollection(); characterName = _jo["characterName"].str; Str = (int)_jo["Str"].n; Dex = (int)_jo["Dex"].n; Con = (int)_jo["Con"].n; Int = (int)_jo["Int"].n; Wis = (int)_jo["Wis"].n; Cha = (int)_jo["Cha"].n; hitPoints = (int)_jo["hitPoints"].n; string[] levelStr = _jo["level"].str.Split('/'); level = new int[levelStr.Length]; for(int i=0; i<levelStr.Length; i++) level[i] = Int32.Parse(levelStr[i]); experiencePoints = (int)_jo["experiencePoints"].n; vision = (int)_jo["vision"].n; move = (int)_jo["move"].n; characterGender = OSRICConstants.GetEnum<OSRIC_GENDER>(_jo["characterGender"].str); characterRace = OSRICConstants.GetEnum<OSRIC_RACE>(_jo["characterRace"].str); characterClass = OSRICConstants.GetEnum<OSRIC_CLASS>(_jo["characterClass"].str); characterAlignment = OSRICConstants.GetEnum<OSRIC_ALIGNMENT>(_jo["characterAlignment"].str); characterState = OSRICConstants.GetEnum<OSRIC_CHARACTER_STATE>(_jo["characterState"].str); foreach(JSONObject obj in _jo["CharacterModifiers"].list) CharacterModifiers.Add(new OSRICCharacterModifier(obj)); }
public void UpdateCharacterOptions(CharacterOptionCollection coc) { //OSRICEngine.RemoveRaceAdjustments(this);//if we really need to call function on the engine from here we're probably in trouble and need to rethink a few things this.ClearRacialModifiers();//this works now without engine call like above characterName = coc.charName; characterRace = coc.charRace; OSRICEngine.AddRaceAdjustments(this,characterRace); characterAlignment = coc.charAlignment; characterGender = coc.charGender; characterClass = coc.charClass; string strout = "Current Modifiers: "; foreach(OSRICCharacterModifier ocm in CharacterModifiers.ModifierList) { strout += ocm.attribute.GetDesc() + " | "; } // Debug.Log(strout); BroadcastRacialAttributeDidChange(); BroadcastAttributeModelDidChange (); }
public int GetClassMaxByRace(OSRIC_RACE _or, OSRIC_CLASS _oc) { int yindex = raceMinMax.GetYIndexOf(_or.GetDesc()); if(yindex<0) return 0; try { return raceMinMax.GetValue(_oc.GetDesc(),yindex); } catch { return 0; } }
public static void AddRaceAdjustments(OSRICAttributeModel oam, OSRIC_RACE newOR) { List<OSRICCharacterModifier> accumulator = new List<OSRICCharacterModifier>(); OSRICCharacterModifier tempMod; switch(newOR) { case OSRIC_RACE.Dwarf: tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Constitution, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, 1); accumulator.Add(tempMod); tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Charisma, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, -1); accumulator.Add(tempMod); break; case OSRIC_RACE.Elf: tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Dexterity, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, 1); accumulator.Add(tempMod); tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Constitution, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, -1); accumulator.Add(tempMod); break; case OSRIC_RACE.Gnome: break; case OSRIC_RACE.HalfElf: break; case OSRIC_RACE.Halfling: tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Dexterity, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, 1); accumulator.Add(tempMod); tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Strength, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, -1); accumulator.Add(tempMod); // Broken here int conAdjust = -1*(int)((float)oam.Con/3.5); tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.savingthrow, OSRIC_SAVING_THROWS.saveRoSaWa, OSRIC_ATTRIBUTES.Constitution, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, conAdjust); accumulator.Add(tempMod); tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.savingthrow, OSRIC_SAVING_THROWS.saveSpell, OSRIC_ATTRIBUTES.Constitution, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, conAdjust); accumulator.Add(tempMod); tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.savingthrow, OSRIC_SAVING_THROWS.saveDeath, OSRIC_ATTRIBUTES.Constitution, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, conAdjust); accumulator.Add(tempMod); break; case OSRIC_RACE.HalfOrc: tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Strength, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, 1); accumulator.Add(tempMod); tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Constitution, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, 1); accumulator.Add(tempMod); tempMod = new OSRICCharacterModifier(OSRIC_CHARACTER_VARIABLES.attribute, OSRIC_ATTRIBUTES.Charisma, OSRIC_ATTRIBUTE_MODIFIER_TYPE.Racial, -2); accumulator.Add(tempMod); break; case OSRIC_RACE.Human: break; } foreach(OSRICCharacterModifier ocm in accumulator) { oam.AddRacialModifier(ocm); } // Debug.Log("Modifier List: " + oam.CharacterModifiers.ModifierList.Count.ToString()); }
private int GetClassLevel(OSRIC_CLASS _oc, OSRIC_RACE _or, int _xp ) { if(!ClassLevels.ContainsKey(_oc)) return -1; int[] classArr = ClassLevels[_oc]; int maxLev = engine.GetClassMaxByRace(_or,_oc); for(int i=0; i < classArr.Length;i++) if(_xp<classArr[i]) { int nextLev = i+1; Debug.Log("Next Level: " + nextLev.ToString()); if(nextLev<maxLev) return nextLev; return maxLev; } if(!UpperLevelTargets.ContainsKey(_oc)) return classArr.Length; int remainder = _xp - classArr[classArr.Length-1]; int newLevel = remainder/UpperLevelTargets[_oc] + classArr.Length; if(newLevel>maxLev) return maxLev; return newLevel; }