public Character CreateCharacter(string factionType, string characterType, string name) { if (!Enum.TryParse <Faction>(factionType, out var factionObj)) { throw new ArgumentException(string.Format(OutputMessage.InvalidFaction, factionType)); } Character character = null; switch (characterType) { case "Warrior": character = new Warrior(name, factionObj); break; case "Cleric": character = new Cleric(name, factionObj); break; default: throw new ArgumentException(string.Format(OutputMessage.InvalidCharacter, characterType)); } return(character); }
public string JoinParty(string[] args) { string faction = args[0]; string characterType = args[1]; string name = args[2]; if (!Enum.TryParse(faction, out Faction factionResult)) { throw new ArgumentException($"Invalid faction \"{faction}\"!"); } if (characterType != "Warrior" && characterType != "Cleric") { throw new ArgumentException($"Invalid character type \"{characterType}\"!"); } Character character; if (characterType == "Warrior") { character = new Warrior(name, factionResult); } else { character = new Cleric(name, factionResult); } characters.Add(character); return($"{name} joined the party!"); }
public string JoinParty(string[] args) { string faction = args[0]; string characterType = args[1]; string name = args[2]; if (!Enum.TryParse <Faction>(faction, out var parsedFaction)) { throw new ArgumentException($"Invalid faction \"{faction}\"!"); } else { switch (characterType) { case "Warrior": Warrior warrior = new Warrior(name, parsedFaction); characters.Add(warrior); break; case "Cleric": Cleric cleric = new Cleric(name, parsedFaction); characters.Add(cleric); break; default: throw new ArgumentException($"Invalid character type \"{characterType}\"!"); } return($"{name} joined the party!"); } }
public string Heal(string[] args) { var healerName = args[0]; var healingReceiverName = args[1]; if (!this.characters.Any(ch => ch.Name == healerName)) { throw new ArgumentException(string.Format(Messages.CharacterNotFound, healerName)); } if (!this.characters.Any(ch => ch.Name == healingReceiverName)) { throw new ArgumentException(string.Format(Messages.CharacterNotFound, healingReceiverName)); } var healer = this.characters.First(ch => ch.Name == healerName); var receiver = this.characters.First(ch => ch.Name == healingReceiverName); if (healer is Warrior) { throw new ArgumentException(string.Format(Messages.CannotHeal, healerName)); } Cleric healerAsCleric = (Cleric)healer; healerAsCleric.Heal(receiver); return($"{healer.Name} heals {receiver.Name} for {healer.AbilityPoints}! {receiver.Name} has {receiver.Health} health now!"); }
public Character CreateCharacter(string factionAsString, string type, string name) { var isParsed = Enum.TryParse <Faction>(factionAsString, out var faction); if (!isParsed) { throw new ArgumentException(string.Format(ExceptionMessages.InvalidFaction, factionAsString)); } Character newCharacter = null; switch (type) { case "Cleric": newCharacter = new Cleric(name, faction); break; case "Warrior": newCharacter = new Warrior(name, faction); break; default: throw new ArgumentException(string.Format(ExceptionMessages.InvalidCharacterType, type)); } return(newCharacter); }
public Character CreateCharacter(string[] args) { string faction = args[0]; string characterType = args[1]; string name = args[2]; Character character = null; bool validFaction = Enum.TryParse(typeof(Character.Faction), faction, out object factionObj); if (!validFaction) { throw new ArgumentException($"Invalid faction \"{faction}\"!"); } if (characterType != "Warrior" && characterType != "Cleric") { throw new ArgumentException($"Invalid character type \"{ characterType }\"!"); } if (characterType == "Warrior") { character = new Warrior(name, (Character.Faction)factionObj); } else if (characterType == "Cleric") { character = new Cleric(name, (Character.Faction)factionObj); } return(character); }
public Character CreateCharacter(string factionStr, string characterType, string name) { if (factionStr != "CSharp" && factionStr != "Java") { string message = factionStr; throw new ArgumentException($"Invalid faction \"{message}\"!"); } if (characterType != "Cleric" && characterType != "Warrior") { throw new ArgumentException($"Invalid character type \"{characterType}\"!"); } Faction faction = Enum.Parse <Faction>(factionStr); Character character = null; if (characterType == "Cleric") { character = new Cleric(name, faction); } else { character = new Warrior(name, faction); } return(character); }
public string Heal(string[] args) { string healerName = args[0]; string healingReceiverName = args[1]; Cleric healer = (Cleric)characterParty.FirstOrDefault(x => x.Name == healerName); Character receiver = characterParty.FirstOrDefault(x => x.Name == healingReceiverName); if (healer == null) { throw new ArgumentException($"Character {healerName} not found!"); } if (receiver == null) { throw new ArgumentException($"Character {healingReceiverName} not found!"); } if (healer.GetType().Name != "Cleric") { throw new ArgumentException($"{healerName} cannot heal!"); } healer.Heal(receiver); return($"{healer.Name} heals {receiver.Name} for {healer.AbilityPoints}! {receiver.Name} has {receiver.Health} health now!"); }
public Character CreateCharacter(string factionArg, string characterType, string name) { Faction faction = new Faction(); if (factionArg == "CSharp") { faction = Faction.CSharp; } else if (factionArg == "Java") { faction = Faction.Java; } else { throw new ArgumentException($"Invalid faction \"{factionArg}\"!"); } Character character = null; if (characterType == "Warrior") { character = new Warrior(name, faction); } else if (characterType == "Cleric") { character = new Cleric(name, faction); } else { throw new ArgumentException($"Invalid character type \"{characterType}\"!"); } return(character); }
public Character CreateCharacter(string[] charArgs) { string factionStr = charArgs[0]; string type = charArgs[1]; string name = charArgs[2]; bool isFactionValid = Enum.TryParse(typeof(Faction), factionStr, out object factionResult); if (!isFactionValid) { throw new ArgumentException(string.Format(ErrorMessages.InvalidFactiont, factionStr)); } Faction faction = (Faction)factionResult; Character character = null; if (type == "Warrior") { character = new Warrior(name, faction); return(character); } else if (type == "Cleric") { character = new Cleric(name, faction); return(character); } throw new ArgumentException(string.Format(ErrorMessages.InvalidCharacter, type)); }
public Character CreateCharacter(string[] args) { string faction = args[0]; string characterType = args[1]; string name = args[2]; Character newCharacter; if (faction != "CSharp" && faction != "Java") { throw new ArgumentException($"Invalid faction \"{ faction }\"!"); } Faction parsedFaction; var toBeParsed = Enum.TryParse(faction, out parsedFaction); switch (characterType) { case "Warrior": newCharacter = new Warrior(name, parsedFaction); break; case "Cleric": newCharacter = new Cleric(name, parsedFaction); break; default: throw new ArgumentException($"Invalid character type \"{ characterType }\"!"); } return(newCharacter); }
public string Heal(string[] args) { string healerName = args[0]; string healingReceiverName = args[1]; Character healer = this.partyList.FirstOrDefault(c => c.Name == healerName); Character healingReceiver = this.partyList.FirstOrDefault(c => c.Name == healingReceiverName); if (healer == null) { throw new ArgumentException($"Character {healerName} not found!"); } if (healingReceiver == null) { throw new ArgumentException($"Character {healingReceiverName} not found!"); } if (healer is Warrior) { throw new ArgumentException($"{healerName} cannot heal!"); } Cleric cleric = (Cleric)healer; cleric.Heal(healingReceiver); return ($"{healer.Name} heals {healingReceiver.Name} for {healer.AbilityPoints}! {healingReceiver.Name} has {healingReceiver.Health} health now!"); }
public Character CreateCharacter(string factionName, string characterType, string name) { if (factionName != "CSharp" && factionName != "Java") { throw new ArgumentException(string.Format(ExceptionMessages.InvalidFactionException, factionName)); } Faction faction = Enum.Parse <Faction>(factionName); if (characterType != "Warrior" && characterType != "Cleric") { throw new ArgumentException(string.Format(ExceptionMessages.InvalidCharacterTypeException, characterType)); } Character character = null; if (characterType == "Warrior") { character = new Warrior(name, faction); } else if (characterType == "Cleric") { character = new Cleric(name, faction); } else { throw new ArgumentException(string.Format(ExceptionMessages.InvalidCharacterTypeException, characterType)); } return(character); }
public Character CreateCharacter(string faction, string characterType, string name) { Character character = null; if (!Enum.TryParse(faction, out Faction factionResult)) { throw new ArgumentException($"Invalid faction \"{faction}\"!"); } switch (characterType) { case "Warrior": character = new Warrior(name, factionResult); break; case "Cleric": character = new Cleric(name, factionResult); break; default: throw new ArgumentException($"Invalid character type \"{characterType}\"!"); } return(character); }
public Character CreateCharacter(string faction, string type, string name) { if (!Enum.TryParse <Faction>(faction, out var parsedFaction)) { throw new ArgumentException($"Invalid faction \"{faction}\"!"); } Character character; switch (type) { case "Warrior": character = new Warrior(name, parsedFaction); break; case "Cleric": character = new Cleric(name, parsedFaction); break; default: throw new ArgumentException($"Invalid character type \"{type}\"!"); } return(character); }
public string JoinParty(string[] args) { object factionParse; if (!Enum.TryParse(typeof(Faction), args[0], out factionParse)) { throw new ArgumentException($"Invalid faction \"{args[0]}\"!"); } Faction faction = (Faction)factionParse; if (args[1] != nameof(Cleric) && args[1] != nameof(Warrior)) { throw new ArgumentException($"Invalid character type \"{ args[1] }\"!"); } Character temp = null; switch (args[1]) { case nameof(Warrior): temp = new Warrior(args[2], faction); break; case nameof(Cleric): temp = new Cleric(args[2], faction); break; } characters.Add(temp.Name, temp); return($"{temp.Name} joined the party!"); }
public string JoinParty(string[] args) { var faction = args[0]; var characterClass = args[1]; var name = args[2]; Faction parsedFaction; if (!Enum.TryParse(faction, out parsedFaction)) { throw new ArgumentException($"Invalid faction \"{faction}\""); } Character character; switch (characterClass) { case "Warrior": character = new Warrior(name, parsedFaction); break; case "Clerik": character = new Cleric(name, parsedFaction); break; default: throw new ArgumentException($"Invalid character type \"{characterClass}\""); } return($"{character.Name} joined the party!"); }
public Character CreateCharacter(string factionParam, string typeParam, string nameParam) { Faction faction; var factionCurrect = Faction.TryParse(factionParam, out faction); var type = typeParam; var name = nameParam; if (!factionCurrect) { throw new ArgumentException($"Invalid faction \"{factionParam}\"!"); } if (type != "Warrior" && type != "Cleric") { throw new ArgumentException(/*string.Format(Inputs.InvalidCaracterType, type)*/ $"Invalid character type \"{type}\"!"); } if (type == "Warrior") { var warrior = new Warrior(name, faction); return(warrior); } else { var cleric = new Cleric(name, faction); return(cleric); } }
public void SetClericLevelTest() { Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 12); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 15); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 3); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 12); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 17); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 1; Cleric cleric = new Cleric("Fryer Ben", Race.Halfling, dict, hp, xp); cleric.IncreaseExperiencePoints(0); Assert.AreEqual(1, cleric.currentLevel, "TEST1: The level is not as expected"); cleric.IncreaseExperiencePoints(1499); Assert.AreEqual(1, cleric.currentLevel, "TEST2: The level is not as expected"); cleric.IncreaseExperiencePoints(1); Assert.AreEqual(2, cleric.currentLevel, "TEST3: The level is not as expected"); cleric.IncreaseExperiencePoints(1499); Assert.AreEqual(2, cleric.currentLevel, "TEST4: The level is not as expected"); cleric.IncreaseExperiencePoints(1); Assert.AreEqual(3, cleric.currentLevel, "TEST5: The level is not as expected"); }
public void Show() { //Debug.Log("<b>Log</b>"); //Debug.LogWarning("<i>Warning</i>"); //Debug.LogError("<color=#ff0000ff>Error</color>"); //Debug.Log("1 - square"); //Debug.Log("2 - circle"); string shapeSelected = inputField.text;//Console.ReadLine(); Class Class = null; switch (shapeSelected) { case "1": Class = new Knight("NewKnight"); break; case "2": Class = new Cleric("NewCleric"); break; case "3": Class = new Warrior("NewWarrior"); break; } if (Class != null) { Debug.Log("Your selected " + Class.Area()); } }
public Character CreateCharacter(string[] args) { Faction?factionType = Enum.TryParse <Faction>(args[0], out var faction) ? faction : (Faction?)null; string characterType = args[1]; string name = args[2]; if (factionType == null) { throw new ArgumentException($"Invalid faction \"{args[0]}\"!"); } Character character; switch (characterType) { case "Warrior": character = new Warrior(name, (Faction)factionType); break; case "Cleric": character = new Cleric(name, (Faction)factionType); break; default: throw new ArgumentException($"Invalid character type {characterType}"); } return(character); }
public string Heal(string[] args) { var healerName = args[0]; var healingReceiverName = args[1]; var giver = Party.FirstOrDefault(c => c.Name == healerName); if (giver == null) { throw new ArgumentException(string.Format(Inputs.CharacterNotFound, healerName)); } var reciver = Party.FirstOrDefault(c => c.Name == healingReceiverName); if (reciver == null) { throw new ArgumentException(string.Format(Inputs.CharacterNotFound, healingReceiverName)); } if (giver.GetType().Name != "Cleric") { throw new ArgumentException($"{healerName} cannot heal!"); } Cleric cleric = (Cleric)giver; cleric.Heal(reciver); return ($"{giver.Name} heals {reciver.Name} for {giver.AbilityPoints}! {reciver.Name} has {reciver.Health} health now!"); }
public string JoinParty(string[] args) { string faction = args[0]; string characterType = args[1]; string name = args[2]; if (!Enum.TryParse(faction, out Faction factionResult)) { throw new ArgumentException($"Invalid faction \"{faction}\"!"); } Character character; switch (characterType) { case "Warrior": character = new Warrior(name, factionResult); break; case "Cleric": character = new Cleric(name, factionResult); break; default: throw new ArgumentException($"Invalid character type \"{characterType}\"!"); } this.characters.Add(character); return($"{name} joined the party!"); }
public static void AddCleric(Character character) { Cleric.Base(character); Cleric.Features(character); Cleric.Equipment(character); character.Archetype = Cleric.DivineDomain; }
public Character CreateCharacter(string faction, string type, string name) { Faction newFaction; bool isParsed = Enum.TryParse <Faction>(faction, out newFaction); if (!isParsed) { throw new ArgumentException($"Invalid faction \"{faction}\"!"); } Character character; if (type == "Warrior") { character = new Warrior(name, newFaction); } else if (type == "Cleric") { character = new Cleric(name, newFaction); } else { throw new ArgumentException($"Invalid character \"{type}\"!"); } return(character); }
public AllSpells(string classStr) { Stat = "Cha"; switch (classStr) { case "Cleric": Cleric.Add(0, ClericSpells.Cantrips); Cleric.Add(1, ClericSpells.FirstLvls); Cleric.Add(2, ClericSpells.SecondLvls); Cleric.Add(3, ClericSpells.ThirdLvls); Cleric.Add(4, ClericSpells.FourthLvls); Cleric.Add(5, ClericSpells.FifthLvls); Cleric.Add(6, ClericSpells.SixthLvls); Cleric.Add(7, ClericSpells.SeventhLvls); Cleric.Add(8, ClericSpells.EigthLvls); Cleric.Add(9, ClericSpells.NinthLvls); break; case "Sorcerer": Sorcerer.Add(0, SorcererSpells.Cantrips); Sorcerer.Add(1, SorcererSpells.FirstLvls); Sorcerer.Add(2, SorcererSpells.SecondLvls); Sorcerer.Add(3, SorcererSpells.ThirdLvls); Sorcerer.Add(4, SorcererSpells.FourthLvls); Sorcerer.Add(5, SorcererSpells.FifthLvls); Sorcerer.Add(6, SorcererSpells.SixthLvls); Sorcerer.Add(7, SorcererSpells.SeventhLvls); Sorcerer.Add(8, SorcererSpells.EigthLvls); Sorcerer.Add(9, SorcererSpells.NinthLvls); break; } }
public void ResetClassStats(List <CharClass> partyMembers) { foreach (var member in partyMembers) { switch (member.classType) { case CharClass.WARRIOR: { Warrior freshClass = new Warrior(); member.itemFind = freshClass.itemFind; member.xpBonus = freshClass.xpBonus; member.coinBonus = freshClass.coinBonus; member.preventDeathBonus = freshClass.preventDeathBonus; member.successChance = freshClass.successChance; } break; case CharClass.MAGE: { Mage freshClass = new Mage(); member.itemFind = freshClass.itemFind; member.xpBonus = freshClass.xpBonus; member.coinBonus = freshClass.coinBonus; member.preventDeathBonus = freshClass.preventDeathBonus; member.successChance = freshClass.successChance; } break; case CharClass.ROGUE: { Rogue freshClass = new Rogue(); member.itemFind = freshClass.itemFind; member.xpBonus = freshClass.xpBonus; member.coinBonus = freshClass.coinBonus; member.preventDeathBonus = freshClass.preventDeathBonus; member.successChance = freshClass.successChance; } break; case CharClass.RANGER: { Ranger freshClass = new Ranger(); member.itemFind = freshClass.itemFind; member.xpBonus = freshClass.xpBonus; member.coinBonus = freshClass.coinBonus; member.preventDeathBonus = freshClass.preventDeathBonus; member.successChance = freshClass.successChance; } break; case CharClass.CLERIC: { Cleric freshClass = new Cleric(); member.itemFind = freshClass.itemFind; member.xpBonus = freshClass.xpBonus; member.coinBonus = freshClass.coinBonus; member.preventDeathBonus = freshClass.preventDeathBonus; member.successChance = freshClass.successChance; } break; default: break; } } }
private void BtnCreate_Click(object sender, RoutedEventArgs e) { String option = CboxCharacter.Text; List <IDescribable> objectList = new List <IDescribable>(); objectList.Add(new Axe()); objectList.Add(new Potion()); objectList.Add(new Wizard { Level = 10 }); IDescribable i = new Fighter(); TxtOutput.Text = ""; foreach (IDescribable d in objectList) { TxtOutput.Text += d.ShowInformation() + "\n"; } Character myCharacter = null; switch (option) { case "Cleric": myCharacter = new Cleric(); break; case "Fighter": myCharacter = new Fighter(); break; case "Rouge": myCharacter = new Rouge(); break; case "Wizard": myCharacter = new Wizard(); break; default: myCharacter = null; MessageBox.Show("You MUST select a type"); break; } myCharacter.Name = "Solrac"; myCharacter.Level = 2; myCharacter.Experience = 10000; if (myCharacter != null) { TxtOutput.Text = myCharacter.Taunt(); } }
private static string[] getSubClassDnD(CLASSES C, int lv) { string[] Sub = new string[20];// may need to change temp size if (C == BARBARIAN) { Sub = Barbarian.getDnD(lv); } else if (C == BARD) { Sub = Bard.getDnD(); } else if (C == CLERIC) { Sub = Cleric.getDnD(D5Core); } else if (C == DRUID) { Sub = Druid.getDnD(D5Core); } else if (C == FIGHTER) { Sub = Fighter.getDnD(D5Core, lv); } else if (C == MONK) { Sub = Monk.getDnD(D5Core, lv); } else if (C == PALADIN) { Sub = Paladin.getDnD(D5Core); } else if (C == RANGER) { Sub = Ranger.getDnD(D5Core, lv); } else if (C == ROGUE) { Sub = Rogue.getDnD(D5Core); } else if (C == SORCERER) { Sub = Sorcerer.getDnD(D5Core, lv); } else if (C == WARLOCK) { Sub = Warlock.getDnD(D5Core, lv); } else if (C == WIZARD) { Sub = Wizard.getDnD(D5Core); } Sub = Vars.shorten <string>(Sub); return(Sub); }
public void SetClass(string user, string choice, IrcClient whisperClient) { switch (choice.ToLower()) { case "c1": { classList[user] = new Warrior(); classList[user].name = user; classList[user].level = determineLevel(user); classList[user].itemEarned = -1; SaveClassData(); whisperClient.sendChatMessage(".w " + user + " You successfully selected the Warrior class!"); } break; case "c2": { classList[user] = new Mage(); classList[user].name = user; classList[user].level = determineLevel(user); classList[user].itemEarned = -1; SaveClassData(); whisperClient.sendChatMessage(".w " + user + " You successfully selected the Mage class!"); } break; case "c3": { classList[user] = new Rogue(); classList[user].name = user; classList[user].level = determineLevel(user); classList[user].itemEarned = -1; SaveClassData(); whisperClient.sendChatMessage(".w " + user + " You successfully selected the Rogue class!"); } break; case "c4": { classList[user] = new Ranger(); classList[user].name = user; classList[user].level = determineLevel(user); classList[user].itemEarned = -1; SaveClassData(); whisperClient.sendChatMessage(".w " + user + " You successfully selected the Ranger class!"); } break; case "c5": { classList[user] = new Cleric(); classList[user].name = user; classList[user].level = determineLevel(user); classList[user].itemEarned = -1; SaveClassData(); whisperClient.sendChatMessage(".w " + user + " You successfully selected the Cleric class!"); } break; default: break; } }