Ejemplo n.º 1
0
 public RecordOfBattleAction(int CharacterWithInitiative, int CharacterBeingTargeted, int CharacterThatPerformedCover, int BattleActionID)
 {
     characterWithInitiative     = FinalGambit.GetCharacterFromCharacterIndex(CharacterWithInitiative);
     characterBeingTargeted      = FinalGambit.GetCharacterFromCharacterIndex(CharacterBeingTargeted);
     characterThatPerformedCover = FinalGambit.GetCharacterFromCharacterIndex(CharacterThatPerformedCover);
     battleActionID = BattleActionID;
 }
Ejemplo n.º 2
0
        static public void ProcessAI()
        {
            #region SampleCode


            PartyCharacter target = null;

            foreach (PartyCharacter pc in FinalGambit.BattleState.foeCharacters)
            {
                if (pc.hp > 0)
                {
                    if (target == null)
                    {
                        target = pc;
                    }
                    else if (pc.hp < target.hp)
                    {
                        target = pc;
                    }
                }
            }

            FinalGambit.PerformBattleAction(FinalGambit.BattleActionID.Attack, target);


            //Console.WriteLine("Char with init: " + FinalGambit.characterWithInitiative);


            //foreach (PartyCharacter pc in FinalGambit.BattleState.partyCharacters)
            //{
            //    foreach(StatusEffect se in pc.statusEffects)
            //    {
            //        if(se.id == FinalGambit.StatusEffectID.Poison)
            //        {
            //            //We have found a character that is poisoned, do something here...
            //        }
            //    }
            //}

            //if(FinalGambit.characterWithInitiative.classID == FinalGambit.CharacterClassID.Fighter)
            //{
            //    //The character with initiative is a figher, do something here...
            //}

            #endregion
        }
Ejemplo n.º 3
0
        private void ReadBattleStateSerializationFile()
        {
            FinalGambit.BattleState = new BattleState();


            FileStream f = File.OpenRead(FileNames.battleState);

            StreamReader sr = new StreamReader(f);

            bool                      isReadingForParty = true;
            PartyCharacter            lastPC            = null;
            LegalActionAndRequirments lastAction        = null;

            // Console.WriteLine("starting reading ");

            string data;

            while ((data = sr.ReadLine()) != null)
            {
                //Console.WriteLine("reading " + data);
                string[] processing = data.Split(",");
                int      identifier = Int32.Parse(processing[0]);

                if (identifier == CoreStats)
                {
                    lastPC = new PartyCharacter(Int32.Parse(processing[1]), Int32.Parse(processing[2]), Int32.Parse(processing[3]), Int32.Parse(processing[4]), Int32.Parse(processing[5]), float.Parse(processing[6]), float.Parse(processing[7]), Int32.Parse(processing[8]), Int32.Parse(processing[9]), Int32.Parse(processing[10]), Int32.Parse(processing[11]));
                    if (isReadingForParty)
                    {
                        FinalGambit.BattleState.partyCharacters.AddLast(lastPC);
                    }
                    else
                    {
                        FinalGambit.BattleState.foeCharacters.AddLast(lastPC);
                    }
                }
                else if (identifier == FoePartyInfoStart)
                {
                    isReadingForParty = false;
                }
                else if (identifier == Perk)
                {
                    lastPC.perkIDs.AddLast(Int32.Parse(processing[1]));
                }
                else if (identifier == StatusEffect)
                {
                    lastPC.statusEffects.AddLast(new StatusEffect(Int32.Parse(processing[1]), Int32.Parse(processing[2])));
                }
                else if (identifier == PassiveAbility)
                {
                    lastPC.passiveAbilities.AddLast(Int32.Parse(processing[1]));
                }
                else if (identifier == Ability)
                {
                    lastPC.battleActions.AddLast(Int32.Parse(processing[1]));
                }
                else if (identifier == PartyInventoryItem)
                {
                    if (isReadingForParty)
                    {
                        FinalGambit.BattleState.partyInventory.AddLast(new InventoryItem(Int32.Parse(processing[1]), Int32.Parse(processing[2])));
                    }
                    else
                    {
                        FinalGambit.BattleState.foeInventory.AddLast(new InventoryItem(Int32.Parse(processing[1]), Int32.Parse(processing[2])));
                    }
                }
                else if (identifier == CharacterWithInitiative)
                {
                    FinalGambit.BattleState.characterWithInitiative = FinalGambit.GetCharacterFromCharacterIndex(Int32.Parse(processing[1]));
                }
                else if (identifier == PossibleAction)
                {
                    lastAction = new LegalActionAndRequirments(Int32.Parse(processing[1]));
                    FinalGambit.BattleState.legalActions.AddLast(lastAction);
                }
                else if (identifier == ActionLegality)
                {
                    //Console.WriteLine("Adding legality " + Int32.Parse(processing[1]) + " to " + FinalGambit.BattleActionID.lookUp[lastAction.actionID]);
                    lastAction.legalities.AddLast(Int32.Parse(processing[1]));
                }
                else if (identifier == RecordOfBattleAction)
                {
                    FinalGambit.recordOfBattleActions.AddLast(new RecordOfBattleAction(Int32.Parse(processing[1]), Int32.Parse(processing[2]), Int32.Parse(processing[3]), Int32.Parse(processing[4])));

                    FileStream f2;
                    if (!File.Exists(FileNames.battleReport))
                    {
                        //Console.WriteLine("report create");
                        f2 = File.Create(FileNames.battleReport);
                    }
                    else
                    {
                        //Console.WriteLine("report append");
                        f2 = File.Open(FileNames.battleReport, FileMode.Append);
                    }

                    StreamWriter sw = new StreamWriter(f2);

                    //Console.WriteLine("report write = " + data);
                    sw.WriteLine("" + data);
                    sw.Close();

                    f2.Close();
                }
                else if (identifier == IsFistStateSentForNewBattle)
                {
                    FinalGambit.recordOfBattleActions = new LinkedList <RecordOfBattleAction>();
                    File.Delete(FileNames.battleReport);
                }
            }
            sr.Close();

            f.Close();
        }