private void RestoreData() { // set the storage and load the building list const string storageColumns = "Date,Army Spr,Army Swrd,Army Axe,Army Scout,Army LC,Army HC,Army Ram,Army Cat,Army Kngt,Army Nbl,Location X,Location Y"; _storage = new StoreData("Farming", storageColumns); var items = _storage.ReadLines(); for (var i = 1; i < items.Length; i++) // do not add the column names to list { //get all the field information from line var fields = items[i].Split(','); // Create the date information var date = Convert.ToDateTime(fields[0]); // Create the army information var armyInfo = new int[10]; for (var j = 1; j < 11; j++) { armyInfo[j - 1] = int.Parse(fields[j]); } var army = new ArmyBuilder(armyInfo); // Create the location information var location = new Village(int.Parse(fields[11]), int.Parse(fields[12])); //Finally create the AttackScheduler item from the information above var item = new AttackScheduler(location, army, date); // Add the created item into the list ScheduleList.Items.Add(item); } }
public Army MoveArmy(ArmyBuilder builder) { builder.Box = _box; builder.CreateArmy(); builder.SetWarriors(); return(builder.Army); }
public void PlayerWithoutCardsCantTrade() { var player = new Player("TestName", 0, 1); var result = ArmyBuilder.TradeCards(player); Assert.IsTrue(result == 0); }
public void ContinentCountIsCorrect() { var earth = MockBuilder.GetEarth(); var player = new Player("TestName", 0, 1); var result = ArmyBuilder.ArmiesForContinentsOccupied(earth, player); Assert.IsTrue(result == 17); }
public void TerritoryCountIsCorrect() { var earth = MockBuilder.GetEarth(); var player = new Player("TestName", 0, 1); var result = ArmyBuilder.ArmiesForTerritoriesOccupied(earth, player); Assert.IsTrue(result == 9); }
private void Start() { if (ab == null) { ab = FindObjectOfType <ArmyBuilder>(); } CH = FindObjectOfType <ChosenHero>(); GetComponent <Button>().onClick.AddListener(TaskOnClick); }
public void ContinentIsRuledByPlayer() { var list = new List <string> { "TestName", "TestName", "TestName", "TestName" }; var result = ArmyBuilder.CheckContinentForRuler(list, "TestName"); Assert.IsTrue(result); }
public override void OnChoice() { base.OnChoice(); UnitStatShower.currentInstance = statShower; armyBuilder = new ArmyBuilder(Global.instance.armySavingManager.currentSave.armySize, leftUnitsList.buttonPrefab, possibleUnits, ownedUnitsTransform); leftUnitsList.CreateButtons(); armyBuilder.LoadPreexistingArmy(Global.instance.armySavingManager.currentSave.GetUnitCreators()); SetRemainingGoldTextTo(armyBuilder.currentMoney); forwardButton.gameObject.SetActive(ownedUnitsTransform.childCount > 0); }
public NavigationSteps(Visitor visitor) { _webSystem = new WebSystem(); _visitor = visitor; VisitorBrowser = _visitor.Browser(); _navigation = new Navigation(VisitorBrowser); _armyBuilder = new ArmyBuilder(VisitorBrowser, BaseUrl); _campaign = new Campaign(VisitorBrowser, BaseUrl); _home = new Home(VisitorBrowser, BaseUrl); _lore = new Lore(VisitorBrowser, BaseUrl); _rules = new Rules(VisitorBrowser, BaseUrl); }
static void Main(string[] args) { string PATH = @"C:\Users\Lenonvo\Documents\itmo-oop\FinalProject\FinalProject\Mods"; List <Unit> availableUnits = new List <Unit>(); foreach (var path in Directory.GetFiles(PATH)) { Assembly.LoadFile(path).GetTypes() .Where(x => x.IsSubclassOf(typeof(Unit))) .Select(x => (Unit)Activator.CreateInstance(x)).ToList().ForEach(x => availableUnits.Add(x)); } availableUnits = availableUnits.Select(x => x).OrderBy(x => x.Name).ToList(); Console.WriteLine("Welcome to the greatest game of the greatest!"); Console.WriteLine("Just let's start!"); Console.WriteLine("First player, please, enter your name:"); string firstPlayerName = Console.ReadLine(); Console.WriteLine("Second player, please, enter your name:"); string secondPlayerName = Console.ReadLine(); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); InformationManager infoManager = new InformationManager(availableUnits); infoManager.getAllInfo(); Console.WriteLine("Let's make your armies! Press Enter to continue..."); Console.ReadLine(); ArmyBuilder armyBuilder = new ArmyBuilder(availableUnits); Army firstArmy = armyBuilder.MakeArmy(firstPlayerName); Army secondArmy = armyBuilder.MakeArmy(secondPlayerName); Battle game = new Battle(firstArmy, firstPlayerName, secondArmy, secondPlayerName, infoManager); Console.WriteLine("Armies are equipped.\nPress Enter to start battle!"); Console.ReadLine(); game.StartBattle(); /* * Add 1 in quantity 3 * Add 7 in quantity 10 * Add 11 in quantity 8 * * Add 5 in quantity 3 * Add 8 in quantity 5 * Add 9 in quantity 8 */ }
void Awake() { if (Instance == null) { Instance = this; } else { Debug.LogError("why"); } startingMoney = SaveLoadManager.Instance.currentSaveValue; currentMoney = startingMoney; UnitsList = new List <Unit>(); windowSetter = FindObjectOfType <WindowSetter>(); }
public Navigator(ArmyBuilder army, int x, int y, URL url) { // instantiate the coordinates OwnCoordinates = new int[2]; _enemyCoordinates = new int[2]; // instruct to attack the village _action = ENUM.FarmActions.Attack; //get the army and coordinates _army = army; _enemyCoordinates[X] = x; _enemyCoordinates[Y] = y; //Place the attack command ErrorFlag = true; // the action is not complated, the flag will set as false once action is complete _attackFlag = false; // attack is not made yet
private static void Attack(string token, string[] args) { var armyInfo = new int[10]; var command = new FarmActions(token); var coordinates = new int[2]; coordinates[X] = int.Parse(args[1]); coordinates[Y] = int.Parse(args[2]); for (var i = 3; i < args.Length; i++) { armyInfo[i - 3] = int.Parse(args[i]); } var army = new ArmyBuilder(armyInfo); command.Attack(coordinates[X], coordinates[Y], army); Console.WriteLine("Attack is made to " + coordinates[X] + "," + coordinates[Y]); Console.ReadKey(); }
private void ArmyAdd_Click(object sender, EventArgs e) { // Instantiate army builder var army = new ArmyBuilder(); try { // Get the army name if (!txtTemplateName.Text.Equals("")) { army.Name = txtTemplateName.Text; } // Get army values if (!txtSpear.Text.Equals("")) { army.Spearman = int.Parse(txtSpear.Text); } if (!txtSwords.Text.Equals("")) { army.Swordsman = int.Parse(txtSwords.Text); } if (!txtAxe.Text.Equals("")) { army.Axeman = int.Parse(txtAxe.Text); } if (!txtLC.Text.Equals("")) { army.LightCavalry = int.Parse(txtLC.Text); } if (!txtHC.Text.Equals("")) { army.HeavyCavalary = int.Parse(txtHC.Text); } if (!txtScout.Text.Equals("")) { army.Scout = int.Parse(txtScout.Text); } if (!txtRam.Text.Equals("")) { army.Ram = int.Parse(txtRam.Text); } if (!txtCat.Text.Equals("")) { army.Catapult = int.Parse(txtCat.Text); } if (!txtKnight.Text.Equals("")) { army.Knight = int.Parse(txtKnight.Text); } if (!txtNoble.Text.Equals("")) { army.Nobleman = int.Parse(txtNoble.Text); } // add the created army into the army list if (army.GetSize() != 0) { ArmyList.Items.Add(army); } } catch (Exception) { // enters here if there is something wrong while parsing string to integer MessageBox.Show("Only numbers are allowed"); } }
public AttackScheduler(Village loc, ArmyBuilder army, DateTime date) { Location = loc; Army = army; Date = date; }