Exemple #1
0
        public void play(Hike nowHike)
        {
            Character subject;

            subject = PlayerInteractions.ChooseCharacter(nowHike);
            consequence.Play(nowHike, subject);
        }
Exemple #2
0
        public int Walk(Hike nowHike)
        {
            Eventt nowEvent;

            Console.WriteLine("Walked into {0}", name);
            while (progress <= tileLength)
            {
                if (!AskToContinue())
                {
                    return(progress);
                }
                int sRating;
                sRating = rnd.Next(0, 100);
                if (sRating < safeness)
                {
                    int sChance = safeEvents.Count;
                    int sEvent  = rnd.Next(0, sChance);
                    nowEvent = safeEvents[sEvent];
                }
                else
                {
                    int dChance = dangerousEvents.Count;
                    int dEvent  = rnd.Next(0, dChance);
                    nowEvent = dangerousEvents[dEvent];
                }
                nowEvent.Play(nowHike);
                progress += 10;
            }
            progress = 0;
            return(-1);
        }
        public static Hike ContinueHike(Hike nowHike)
        {
            string name;

            Console.WriteLine("Enter hike name");
            name = Console.ReadLine();
            List <Character> characters = nowHike.GetAllCharacters();
            Storage          storage    = nowHike.GetStorage();

            Console.WriteLine("Choose quest");
            TileWithCoords choosenTile   = Map.ChooseTileOnMap(nowHike.GetHikePlacement());
            List <Eventt>  choosenQuests = ReadLoadTile.ReadTileById(choosenTile.GetTile()).GetQuests();
            Coords         destination   = choosenTile.GetCoords();
            int            i             = 0;

            foreach (Eventt qst in choosenQuests)
            {
                Console.WriteLine("{0}. {1}", i, qst.GetName());
                i++;
            }
            int    cho   = PlayerInput.Input(0, choosenQuests.Count());
            Eventt quest = choosenQuests[cho];

            Console.WriteLine("Choose Path");
            List <Coords> path = Map.BuildPath(nowHike.GetHikePlacement(), destination);

            return(new Hike(name, characters, path, quest, storage));
        }
        public static void ChooseItem(Hike nowHike, Character subject)
        {
            int i = 0;
            int cho;

            if (nowHike.GetStorage().GetAllItems().Count() != 0)
            {
                do
                {
                    Console.WriteLine("Choose an item:");
                    foreach (Item itm in nowHike.GetStorage().GetAllItems())
                    {
                        Console.WriteLine("{0}. {1}", i, itm.GetName());
                        i++;
                    }
                    Console.WriteLine("{0}. Return", i);
                    i   = 0;
                    cho = PlayerInput.Input(0, nowHike.GetStorage().GetAllItems().Count() + 1);
                    Console.Write("\n");
                    if (cho >= 0 && cho < nowHike.GetStorage().GetAllItems().Count())
                    {
                        if (ChooseUseOfItem(nowHike.GetStorage().GetAllItems()[cho], nowHike, subject))
                        {
                            nowHike.GetStorage().GetAllItems().RemoveAt(cho);
                        }
                    }
                } while (cho != nowHike.GetStorage().GetAllItems().Count());
            }
        }
        public static Hike ChooseHikesOrCreateNew()
        {
            Hike hike = null;
            int  i    = 0;

            Console.WriteLine("Choose Hike:");

            return(hike);
        }
        public static void SetIds()
        {
            int maxId = 0;

            while (CheckHikeExistion(Convert.ToString(maxId)))
            {
                maxId++;
            }
            Hike.SetMaxId(maxId);
            Character.SetMaxId(ReadCharactersMaxId());
        }
Exemple #7
0
 public void play(Hike nowHike)
 {
     if (Functions.Test(nowHike.GetStrongAttr(attribute), nowHike.GetStrongTalent(attribute, skill), difficulty))
     {
         Console.WriteLine("Good");
     }
     else
     {
         Console.WriteLine("Bad");
     }
 }
Exemple #8
0
 public void play(Hike nowHike)
 {
     foreach (Character character in nowHike.GetAllCharacters())
     {
         Town.AddFreeCharacter(character);
     }
     foreach (Item item in nowHike.GetStorage().GetAllItems())
     {
         Town.AddStorageItem(item);
     }
     nowHike.EndOfTheHike();
 }
Exemple #9
0
 public void play(Hike nowHike)
 {
     if (PlayerInteractions.ChoosePassiveUse(passiveUseName, nowHike) >= requiredLevel)
     {
         Console.WriteLine(gDescription);
         nextEventt.Play(nowHike);
     }
     else
     {
         Console.WriteLine(bDescription);
     }
 }
Exemple #10
0
 public void play(Hike nowHike)
 {
     if (Functions.Test(nowHike.GetStrongAttr(attribute), nowHike.GetStrongTalent(attribute, skill), difficulty))
     {
         Console.WriteLine(gDescription);
         nowHike.AddItem(new Item(item));
     }
     else
     {
         Console.WriteLine(bDescription);
     }
 }
Exemple #11
0
        public void play(Hike nowHike)
        {
            Character subject;

            subject = PlayerInteractions.ChooseCharacter(nowHike);
            if (Functions.TestCharacter(attribute, talent, difficulty, subject))
            {
                nextGoodEventt.Play(nowHike);
            }
            else
            {
                nextBadEventt.Play(nowHike);
            }
        }
        public static Character ChooseCharacter(Hike nowHike)
        {
            Character subject = null;
            int       i       = 0;

            Console.WriteLine("Choose character:");
            foreach (Character s in nowHike.GetAllCharacters())
            {
                Console.WriteLine("{0} {1}", i, s.GetName());
                i++;
            }
            subject = nowHike.GetAllCharacters()[PlayerInput.Input(0, nowHike.GetAllCharacters().Count())];
            return(subject);
        }
Exemple #13
0
        public void play(Hike nowHike)
        {
            Character subject;

            subject = PlayerInteractions.ChooseCharacter(nowHike);
            if (Functions.Test(subject.GetAttributeValue(attribute), subject.GetTalentValue(attribute, skill), difficulty))
            {
                Console.WriteLine(gDescription);
            }
            else
            {
                subject.DamageCharacter(damage);
                Console.WriteLine(bDescription);
            }
        }
Exemple #14
0
 public void play(Hike nowHike)
 {
     foreach (Character subject in nowHike.GetAllCharacters())
     {
         if (Functions.Test(subject.GetAttributeValue(attribute), subject.GetTalentValue(attribute, skill), difficulty))
         {
             Console.WriteLine("{0} {1}", subject.GetName(), gDescription);
             gConsequence.Play(nowHike, subject);
         }
         else
         {
             Console.WriteLine("{0} {1}", subject.GetName(), bDescription);
             bConsequence.Play(nowHike, subject);
         }
     }
 }
Exemple #15
0
        public static Hike LoadHike(int id)
        {
            Hike        hike    = null;
            XmlDocument xACPDoc = new XmlDocument();

            xACPDoc.Load(AllHikesPathsPath);
            if (Functions.CheckHikeExistion(Convert.ToString(id)))
            {
                XmlDocument hikeDocument          = new XmlDocument();
                string      characterDocumentPath = prefix + namePrefix + id + extention;
                hikeDocument.Load(characterDocumentPath);
                XmlNode          hikeRoot   = hikeDocument.DocumentElement;
                string           name       = hikeRoot.ChildNodes[0].InnerText;
                int              progress   = Convert.ToInt32(hikeRoot.ChildNodes[1].InnerText);
                List <Character> characters = new List <Character> {
                };
                foreach (XmlNode characterNode in hikeRoot.ChildNodes[2])
                {
                    characters.Add(ReadLoadCharacter.ReadCharacterBySideAndId(characterNode.InnerText));
                }
                List <Coords> coords = new List <Coords> {
                };
                Coords coord;
                foreach (XmlNode coordNode in hikeRoot.ChildNodes[3])
                {
                    coord = new Coords(Convert.ToInt32(coordNode.ChildNodes[0].InnerText), Convert.ToInt32(coordNode.ChildNodes[1].InnerText));
                    coords.Add(coord);
                }
                Eventt quest = ReadLoadTile.GetEventt(hikeRoot.ChildNodes[4]);//!!!!!!!!!
                ReadLoadTile.tCheck();
                XmlNode StorageNode = hikeRoot.ChildNodes[5];
                int     maxVolume   = Convert.ToInt32(StorageNode.ChildNodes[0].InnerText);
                int     maxMass     = Convert.ToInt32(StorageNode.ChildNodes[1].InnerText);

                List <Item> items = new List <Item> {
                };
                foreach (XmlNode itemNode in StorageNode.ChildNodes[2])
                {
                    items.Add(ReadLoadItem.ReadItemById(Convert.ToInt32(itemNode.InnerText)));
                }
                Storage storage = new Storage(items, maxVolume, maxMass);
                hike = new Hike(name, progress, characters, coords, quest, storage);
            }
            return(hike);
        }
Exemple #16
0
        public void play(Hike nowHike)
        {
            Character subject;

            subject = PlayerInteractions.ChooseCharacter(nowHike);
            if (Functions.Test(subject.GetAttributeValue(attribute), subject.GetTalentValue(attribute, skill), difficulty))
            {
                Console.WriteLine(gDescription);
                foreach (Character subj in nowHike.GetAllCharacters())
                {
                    gConsequence.Play(nowHike, subj);
                }
            }
            else
            {
                Console.WriteLine(bDescription);
                foreach (Character subj in nowHike.GetAllCharacters())
                {
                    bConsequence.Play(nowHike, subj);
                }
            }
        }
Exemple #17
0
        public int Play(Hike nowHike)
        {
            Console.WriteLine(name);
            int i = 0;

            foreach (IChoice choice in choices)
            {
                choice.writeDescription(i);
                i++;
            }
            while (continuee)
            {
                int cho = PlayerInput.Input(0, choices.Count);
                Console.Write("\n");
                choices[cho].play(nowHike);
                continuee = false;
            }
            continuee = true;
            int progress = 10;

            progress += nowHike.GetProgressChanger();
            return(progress);
        }
        public static int ChoosePassiveUse(string passiveUseName, Hike nowHike)
        {
            List <Item> items = nowHike.GetStorage().FindPassiveUses(passiveUseName);

            if (items.Count() == 0)
            {
                return(0);
            }
            else
            {
                int i = 0;
                int cho;
                Console.WriteLine("Choose Item:");
                foreach (Item itm in items)
                {
                    Console.WriteLine("{0}. {1}", i, itm.GetName());
                    Console.WriteLine("Level: {0}", itm.FindPassiveUses(passiveUseName));
                    i++;
                }
                Console.WriteLine("{0}. Don't use any", i);
                do
                {
                    cho = Convert.ToInt32(Console.ReadKey().KeyChar) - 48;
                    if (cho >= 0 && cho < items.Count())
                    {
                        return(items[cho].FindPassiveUses(passiveUseName));
                    }
                    else
                    {
                        if (cho == items.Count())
                        {
                            return(0);
                        }
                    }
                } while (true);
            }
        }
        public static bool ChooseUseOfItem(Item itm, Hike nowHike, Character subject)
        {
            int  i = 0;
            int  cho;
            bool consume   = false;
            bool continuee = true;

            if (itm.GetAllUseItems().Count() != 0)
            {
                Console.WriteLine("Choose the use of the item:");
                foreach (UseItem use in itm.GetAllUseItems())
                {
                    Console.WriteLine("{0}. {1}", i, use.GetDescription());
                    i++;
                }
                Console.WriteLine("{0}. Return", i);
                do
                {
                    cho = Console.ReadKey().KeyChar - 48;
                    if (cho >= 0 && cho < itm.GetAllUseItems().Count())
                    {
                        if (itm.UseItem(cho, nowHike, subject))
                        {
                            consume   = true;
                            continuee = false;
                        }
                    }
                    else
                    if (cho == itm.GetAllUseItems().Count())
                    {
                        continuee = false;
                    }
                } while (continuee);
            }
            return(consume);
        }
Exemple #20
0
        public static void SaveHike(Hike hike)
        {
            string    id   = Convert.ToString(hike.GetId());
            string    name = hike.GetName();
            string    characterFileName = prefix + namePrefix + id + extention;
            XDocument characterFile     = new XDocument();
            XElement  rootElement       = new XElement(namePrefix + id);
            XElement  hikeName          = Functions.CreateElement("name", name);

            rootElement.Add(hikeName);
            rootElement.Add(Functions.CreateElement("progress", Convert.ToString(hike.GetProgress())));
            XElement characterElement = new XElement("characters");

            foreach (Character character in hike.GetAllCharacters())
            {
                characterElement.Add(Functions.CreateElement("characterTrueId", Convert.ToString(character.GetSide()) + Convert.ToString(character.GetId())));
            }
            rootElement.Add(characterElement);
            XElement pathElement = new XElement("path");
            XElement coordElement;

            foreach (Coords coords in hike.GetCoords())
            {
                coordElement = new XElement("coords");
                coordElement.Add(Functions.CreateElement("x", Convert.ToString(coords.Get()[1])));
                coordElement.Add(Functions.CreateElement("y", Convert.ToString(coords.Get()[0])));
                pathElement.Add(coordElement);
            }
            rootElement.Add(pathElement);
            XElement questElement;
            string   questName       = hike.GetQuest().GetName();
            Coords   questTileCoords = hike.GetCoords()[hike.GetCoords().Count - 1];
            Tile     questTile       = ReadLoadTile.ReadTileById(Map.GetTileByCoords(questTileCoords));
            int      i = 0;

            foreach (Eventt tileQuest in questTile.GetQuests())
            {
                if (tileQuest.GetName() == questName)
                {
                    break;
                }
                i++;
            }
            XmlDocument tileDocument     = ReadLoadTile.GetTileDocumentById(Map.GetTileByCoords(questTileCoords));
            XmlNode     root             = tileDocument.DocumentElement;
            XmlNode     allQuestsElement = root.ChildNodes[7];

            questElement = XElement.Load(allQuestsElement.ChildNodes[i].CreateNavigator().ReadSubtree());
            rootElement.Add(questElement);
            XElement storageElement = new XElement("storage");

            storageElement.Add(Functions.CreateElement("maxVolume", Convert.ToString(hike.GetStorage().GetMaxVolume())));
            storageElement.Add(Functions.CreateElement("maxMass", Convert.ToString(hike.GetStorage().GetMaxMass())));
            XElement itemsElement = new XElement("Items");

            foreach (Item item in hike.GetStorage().GetAllItems())
            {
                itemsElement.Add(Functions.CreateElement("item", Convert.ToString(item.GetId())));
            }
            storageElement.Add(itemsElement);
            rootElement.Add(storageElement);
            characterFile.Add(rootElement);
            characterFile.Save(characterFileName);
            if (!Functions.CheckHikeExistion(Convert.ToString(id)))
            {
                XDocument xDocument = XDocument.Load(AllHikesPathsPath);
                xDocument.Root.Add(Functions.CreateElement(namePrefix + id, prefix + namePrefix + id + extention));
                xDocument.Save(AllHikesPathsPath);
            }
        }
Exemple #21
0
 public void play(Hike nowHike)
 {
     Console.WriteLine(skip);
 }
Exemple #22
0
 public void play(Hike nowHike)
 {
     Console.WriteLine("Battle has started");
     PlayerInteractions.StartBattle(nowHike, ReadLoadFight.ReadPlayerActionList(), ReadLoadFight.ReadTactic(idd));
 }
Exemple #23
0
 public void play(Hike nowHike)
 {
     nextEventt.Play(nowHike);
 }
Exemple #24
0
 public bool UseItem(int index, Hike nowHike, Character subject)
 {
     return(uses[index].Use(nowHike, subject));
 }
        public static void StartBattle(Hike hike, List <List <IAction> > listOfActionLists, List <Tactic> enemyCharactersTactics)
        {
            bool          continuue = true;
            int           i;
            int           j;
            int           w;
            int           cho;
            List <Tactic> characterTactics = new List <Tactic> {
            };

            foreach (Character character in hike.GetAllCharacters())
            {
                characterTactics.Add(new Tactic(listOfActionLists[0], character));
            }
            while (continuue)
            {
                Console.WriteLine("Choose Character");
                j = 0;

                foreach (Tactic tactic in characterTactics)
                {
                    Console.WriteLine("{0}. {1}", j, tactic.GetCharacter().GetName());
                    i = 0;
                    j++;
                    foreach (IAction action in tactic.GetActions())
                    {
                        Console.WriteLine(" {0} {1}", i, action.GetName());
                        i++;
                    }
                }
                Console.WriteLine("{0}. Start Fight", j);
                Console.Write("\n");

                cho = PlayerInput.Input(0, hike.GetAllCharacters().Count() + 1);
                if (cho >= 0 && cho < hike.GetAllCharacters().Count())
                {
                    j = 0;

                    Console.WriteLine("Choose actions");
                    foreach (List <IAction> actionList in listOfActionLists)
                    {
                        Console.Write("{0}: ", j);
                        j++;
                        i = 0;
                        foreach (IAction action in actionList)
                        {
                            Console.WriteLine(" {0} {1}", i, action.GetName());
                            i++;
                        }
                    }
                    w = PlayerInput.Input(0, listOfActionLists.Count());
                    characterTactics.RemoveAt(cho);
                    characterTactics.Insert(cho, new Tactic(listOfActionLists[w], hike.GetAllCharacters()[cho]));
                }
                else
                {
                    if (cho == hike.GetAllCharacters().Count())
                    {
                        continuue = false;
                    }
                }
            }
            Fight fight = new Fight(characterTactics, enemyCharactersTactics);

            Console.WriteLine(fight.Ffight());
        }
Exemple #26
0
 public bool Use(Hike nowHike, Character subject)
 {
     consequence.Play(nowHike, subject);
     return(consume);
 }