Ejemplo n.º 1
0
        /// <summary>
        /// Check that a CrewMember name is unique within this Team
        /// </summary>
        internal void UniqueNameCheck(CrewMember cm)
        {
            var unqiue           = false;
            var partialFailCount = 0;

            //if the name is already in use by another character, reset their name
            while (!unqiue)
            {
                if (partialFailCount < 5)
                {
                    partialFailCount++;
                    var firstNames = crewMembers.Select(c => c.Value.FirstName).Concat(RetiredCrew.Select(c => c.Value.FirstName)).Concat(Recruits.Select(c => c.Value.FirstName)).ToList();
                    var lastNames  = crewMembers.Select(c => c.Value.LastName).Concat(RetiredCrew.Select(c => c.Value.LastName)).Concat(Recruits.Select(c => c.Value.LastName)).ToList();
                    if (firstNames.Contains(cm.FirstName) || lastNames.Contains(cm.LastName) || cm.Name == ManagerName)
                    {
                        cm.SelectRandomName();
                    }
                    else
                    {
                        unqiue = true;
                    }
                }
                else
                {
                    if (crewMembers.ContainsKey(cm.Name) || RetiredCrew.ContainsKey(cm.Name) || Recruits.ContainsKey(cm.Name) || cm.Name == ManagerName)
                    {
                        cm.SelectRandomName();
                    }
                    else
                    {
                        unqiue = true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Assign a CrewMember to a Position
 /// </summary>
 public void AssignCrewMember(Position position, CrewMember crewMember)
 {
     if (position != Position.Null)
     {
         //if a Position is provided and has a CrewMember already assigned to it, remove them from that position
         if (PositionCrew.ContainsKey(position))
         {
             AssignCrewMember(Position.Null, PositionCrew[position]);
         }
     }
     if (crewMember != null)
     {
         //if a CrewMember is provided and is assigned to a position, remove them from that position
         var current = GetCrewMemberPosition(crewMember);
         if (current != Position.Null)
         {
             PositionCrew.Remove(current);
             PositionScores.Remove(current);
         }
         if (position != Position.Null)
         {
             //add combination of CrewMember and Position to PositionCrew dictionary
             PositionCrew.Add(position, crewMember);
             PositionScores.Add(position, 0);
             crewMember.UpdateSingleBelief(NPCBelief.Position, position);
         }
         else
         {
             crewMember.UpdateSingleBelief(NPCBelief.Position);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the highest rated skill for this CrewMember
        /// </summary>
        private Skill GetBestSkill(CrewMember crewMember)
        {
            var bestSkill      = Skill.Charisma;
            var bestSkillLevel = 0;

            //for each available skill
            foreach (Skill skill in Enum.GetValues(typeof(Skill)))
            {
                //no Body avatar parts at the moment, so this skill is skipped
                if (skill == Skill.Body)
                {
                    continue;
                }
                //if the skill rating is equal to the current highest, randomly select if it should become the new bestSkill
                if (crewMember.Skills[skill] == bestSkillLevel)
                {
                    if (StaticRandom.Int(0, 100) % 2 == 0)
                    {
                        bestSkillLevel = crewMember.Skills[skill];
                        bestSkill      = skill;
                    }
                }
                //if the skill rating is higher, make this skill the new bestSkill
                if (crewMember.Skills[skill] > bestSkillLevel)
                {
                    bestSkillLevel = crewMember.Skills[skill];
                    bestSkill      = skill;
                }
            }
            return(bestSkill);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Get the value from the config
 /// </summary>
 public float GetConfigValue(ConfigKey eventKey, CrewMember member = null)
 {
     if (eventKey == ConfigKey.StatRevealCost && member != null)
     {
         return((int)(member.RevealedSkills.Count(s => s.Value != 0) * GetConfigValue(ConfigKey.StatRevealCost)) + (member.RevealedSkills.All(s => s.Value != 0) ? 0 : 1));
     }
     return(eventKey.GetValue());
 }
Ejemplo n.º 5
0
 public PostRaceEventState(CrewMember crewMember, DialogueStateActionDTO dialogue, List <string> subs = null)
 {
     if (subs == null)
     {
         subs = new List <string>();
     }
     CrewMember = crewMember;
     Dialogue   = dialogue;
     Subjects   = subs;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Get the current score for this Position on this Boat for this CrewMember
        /// </summary>
        internal void UpdateCrewMemberScore(Position position, CrewMember crewMember, string managerName)
        {
            //Get the combined average skill rating, mood and manager opinion for this CrewMember in this Position
            var crewScore = GetPositionRating(crewMember, position, managerName);

            //add weighted average opinion to get score for crew member
            crewScore += crewMember.GetOpinionRating(PositionCrew.Values.Select(c => c.Name).ToList());

            PositionScores[position] = crewScore;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Remove a CrewMember from the crew if the player has the allowances to do so
        /// </summary>
        public void RetireCrewMember(CrewMember crewMember)
        {
            var cost = ConfigKey.FiringCost.GetIntValue();

            if (cost <= ActionAllowance && CrewEditAllowance > 0 && Team.CanRemoveFromCrew())
            {
                Team.RetireCrew(crewMember);
                DeductCrewEditAllowance();
                DeductCost(cost);
                Team.Manager.SaveStatus();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Send player meeting dialogue to a CrewMember, getting their response in return
        /// </summary>
        public List <string> SendMeetingEvent(string eventName, CrewMember member)
        {
            var cost = (int)GetConfigValue((ConfigKey)Enum.Parse(typeof(ConfigKey), eventName + "Cost"), member);

            if (cost <= ActionAllowance)
            {
                var reply = EventController.SendMeetingEvent(eventName, member, Team);
                DeductCost(cost);
                Team.Manager.SaveStatus();
                return(reply);
            }
            return(new List <string>());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// If the player has enough time, hire the selected recruit and take the cost from the allowances
        /// </summary>
        public void AddRecruit(CrewMember member)
        {
            //if the player is able to take this action
            var cost = ConfigKey.RecruitmentCost.GetIntValue();

            if (cost <= ActionAllowance && CrewEditAllowance > 0 && Team.CanAddToCrew())
            {
                Team.AddRecruit(member);
                DeductCrewEditAllowance();
                DeductCost(cost);
                Team.Manager.SaveStatus();
            }
        }
Ejemplo n.º 10
0
        internal Avatar(CrewMember crewMember, bool isActive = true)
        {
            //set outfit type
            var outfit = isActive ? "0" + ((StaticRandom.Int(0, 100) % 2) + 2) : "01";

            _gender           = crewMember.Gender;
            CustomOutfitColor = isActive;
            //attempt to recreate pre-existing avatar if one already exists, create new avatar otherwise
            CreateAvatar(crewMember);
            //set outfit according to type, best skill and gender
            OutfitBaseType      = $"Outfit{_gender}_Base_{_bodyType}_{outfit}";
            OutfitHighlightType = $"Outfit{_gender}_Highlight_{_bodyType}_{outfit}";
            OutfitShadowType    = $"Outfit{_gender}_Shadow_{_bodyType}_{outfit}";
        }
        /// <summary>
        /// Get the average skill rating for this CrewMember in this Position
        /// </summary>
        internal static int GetPositionRating(this Position position, CrewMember crewMember)
        {
            var positionCount = 0;
            var crewScore     = 0;

            foreach (var skill in position.RequiredSkills())
            {
                crewScore += crewMember.Skills[skill];
                positionCount++;
            }

            crewScore = (int)Math.Round((float)crewScore / positionCount);

            return(crewScore);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Retire a CrewMember, meaning they can no longer be assigned to a position (mostly used for historical positions)
        /// </summary>
        internal void RetireCrew(CrewMember crewMember)
        {
            var current = Boat.GetCrewMemberPosition(crewMember);

            if (current != Position.Null)
            {
                Boat.AssignCrewMember(current, null);
            }
            crewMembers.Remove(crewMember.Name);
            RetiredCrew.Add(crewMember.Name, crewMember);
            crewMember.Retire();
            foreach (var cm in crewMembers.Values)
            {
                cm.CrewOpinions.Remove(crewMember.Name);
                cm.RevealedCrewOpinions.Remove(crewMember.Name);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Update the current type of Boat to use for this Team
        /// </summary>
        internal void PromoteBoat()
        {
            var extraMembers = Boat.PositionCount;
            var newType      = PromotionTriggerCheck();

            if (string.IsNullOrEmpty(newType))
            {
                return;
            }
            Boat.Promote(newType);
            //store that the boat type has been changed
            Manager.UpdateSingleBelief(NPCBelief.BoatType, Boat.Type);
            if (Boat.Type == "Finish")
            {
                Finished = true;
                return;
            }
            //calculate how many new members should be created
            extraMembers = (Boat.PositionCount - extraMembers) * 2;
            //reset the positions on the boat to those for the new type
            for (var i = 0; i < extraMembers; i++)
            {
                var currentNames = crewMembers.Keys.ToList();
                currentNames.Add(ManagerName);
                //only create a new CrewMember if the crew limit can support it
                if (CanAddToCrew())
                {
                    var position  = Boat.GetWeakestPosition(CrewMembers.Values.Concat(Recruits.Values).ToList());
                    var newMember = new CrewMember(position, Nationality);
                    UniqueNameCheck(newMember);
                    newMember.CreateTeamMemberFile(iat, storageLocation, currentNames, TeamColorsPrimary, TeamColorsSecondary);
                    foreach (var cm in crewMembers.Values)
                    {
                        cm.CreateInitialOpinions(new List <string> {
                            newMember.Name
                        });
                    }
                    //if the boat is under-staffed for the current boat size, this new CrewMember is not counted
                    if (!CanRemoveFromCrew())
                    {
                        i--;
                    }
                    AddCrewMember(newMember);
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Get the best possible position for a crew member ohter than their current position
        /// </summary>
        private KeyValuePair <Position, int> CrewMemberBestPosition(CrewMember cm, Team team)
        {
            var betterPosition  = new KeyValuePair <Position, int>(Position.Null, 0);
            var currentPosition = team.PreviousSession.PositionCrew.SingleOrDefault(pair => pair.Value == cm).Key;

            foreach (var boatPosition in team.PreviousSession.Positions)
            {
                if (boatPosition == currentPosition)
                {
                    continue;
                }
                var possiblePositionScore = boatPosition.GetPositionRating(cm);
                if ((currentPosition != Position.Null && possiblePositionScore > team.PreviousSession.PositionScores[currentPosition]) || possiblePositionScore > betterPosition.Value)
                {
                    betterPosition = new KeyValuePair <Position, int>(boatPosition, possiblePositionScore);
                }
            }
            return(betterPosition);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Update the set of recruits
        /// </summary>
        internal void CreateRecruits()
        {
            var recuritsToRemove = new List <string>();

            //remove recruits from iat and randomly select to remove them from pool of available recruits
            foreach (var member in Recruits)
            {
                var path = Path.Combine(storageLocation, member.Value.RolePlayCharacter.VoiceName + ".rpc").Replace("\\", "/");
                iat.RemoveCharacters(new List <int> {
                    iat.GetAllCharacterSources().First(c => c.Source.Replace("\\", "/") == path).Id
                });
                if (StaticRandom.Int(0, 100) % ConfigKey.RecruitChangeChance.GetIntValue() != 0)
                {
                    recuritsToRemove.Add(member.Key);
                }
            }
            foreach (var member in recuritsToRemove)
            {
                Recruits.Remove(member);
            }

            //for the amount of empty recruit spaces, create a new recruit
            var amount = ConfigKey.RecruitCount.GetIntValue() - Recruits.Count;

            for (var i = 0; i < amount; i++)
            {
                var position  = Boat.GetWeakestPosition(CrewMembers.Values.Concat(Recruits.Values).ToList());
                var newMember = new CrewMember(position, Nationality);
                UniqueNameCheck(newMember);
                Recruits.Add(newMember.Name, newMember);
            }
            var storeNum = 0;

            //set up the files for each recruit and their avatar
            foreach (var recruit in Recruits)
            {
                recruit.Value.CreateRecruitFile(iat, storageLocation, storeNum);
                storeNum++;
            }
            iat.Save();
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Save the current attributes of the CrewMember to their EmotionalAppraisal Asset
 /// </summary>
 internal void UpdateAvatarBeliefs(CrewMember crewMember)
 {
     crewMember.UpdateSingleBelief(NPCBelief.AvatarBestSkill, _bestSkill);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarBodyType, BodyType);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarEyebrowType, EyebrowType);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarEyeType, EyeType);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarEyeColorRed, EyeColor.R);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarEyeColorGreen, EyeColor.G);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarEyeColorBlue, EyeColor.B);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarHairColorRed, HairColor.R);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarHairColorGreen, HairColor.G);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarHairColorBlue, HairColor.B);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarHairType, HairType);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarHeight, Height);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarMouthType, MouthType);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarMouthColor, MouthColor);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarTeethType, TeethType);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarNoseType, NoseType);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarSkinColorRed, SkinColor.R);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarSkinColorGreen, SkinColor.G);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarSkinColorBlue, SkinColor.B);
     crewMember.UpdateSingleBelief(NPCBelief.AvatarWeight, Weight);
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Add a recruit into crewMembers
        /// </summary>
        internal void AddRecruit(CrewMember member)
        {
            //remove recruit from the current list of characters in the game
            var path = Path.Combine(storageLocation, member.RolePlayCharacter.VoiceName + ".rpc").Replace("\\", "/");

            iat.RemoveCharacters(new List <int> {
                iat.GetAllCharacterSources().First(c => c.Source.Replace("\\", "/") == path).Id
            });
            //set up recruit as a 'proper' character in the game
            var currentNames = crewMembers.Keys.ToList();

            currentNames.Add(ManagerName);
            member.CreateTeamMemberFile(iat, storageLocation, currentNames, TeamColorsPrimary, TeamColorsSecondary);
            foreach (var cm in crewMembers.Values)
            {
                cm.CreateInitialOpinions(new List <string> {
                    member.Name
                }, true);
            }
            AddCrewMember(member);
            Recruits.Remove(member.Name);
            iat.Save();
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Get the current Position (if any) of a CrewMember
 /// </summary>
 public Position GetCrewMemberPosition(CrewMember crewMember)
 {
     return(PositionCrew.SingleOrDefault(pair => pair.Value == crewMember).Key);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Send player meeting dialogue to a CrewMember, getting their response in return
 /// </summary>
 internal List <string> SendMeetingEvent(string eventName, CrewMember member, Team team)
 {
     return(member.SendMeetingEvent(iat, eventName, team));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Get the combined average skill rating, mood and manager opinion for this CrewMember in this Position
 /// </summary>
 internal int GetPositionRating(CrewMember member, Position pos, string managerName)
 {
     return(pos.GetPositionRating(member) + (int)(member.GetMood() * ConfigKey.MoodRatingWeighting.GetValue()) + (int)(member.CrewOpinions[managerName] * ConfigKey.ManagerOpinionRatingWeighting.GetValue()));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Add a CrewMember to the list of CrewMembers
 /// </summary>
 internal void AddCrewMember(CrewMember crewMember)
 {
     crewMembers.Add(crewMember.Name, crewMember);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Create a new Avatar based on randomness and this Crew Member's best skill or load the existing Avatar for this Crew Member
        /// </summary>
        private void CreateAvatar(CrewMember crewMember)
        {
            //Get Best Skill
            var currentBestSkill = crewMember.LoadBelief(NPCBelief.AvatarBestSkill);

            _bestSkill = Enum.TryParse <Skill>(currentBestSkill, out var loadedBestSkill) ? loadedBestSkill : GetBestSkill(crewMember);
            _bodyType  = GetBodyType();

            //Set Skin Color
            var loadedMouthColor = crewMember.LoadBelief(NPCBelief.AvatarMouthColor);

            if (loadedMouthColor != null &&
                byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarSkinColorRed), out var skinColorRed) &&
                byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarSkinColorGreen), out var skinColorGreen) &&
                byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarSkinColorBlue), out var skinColorBlue))
            {
                SkinColor  = new Color(skinColorRed, skinColorGreen, skinColorBlue);
                MouthColor = loadedMouthColor;
            }
            else
            {
                SkinColor = GetRandomSkinColor();
            }

            //Set Hair Color
            if (byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarHairColorRed), out var hairColorRed) &&
                byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarHairColorGreen), out var hairColorGreen) &&
                byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarHairColorBlue), out var hairColorBlue))
            {
                HairColor = new Color(hairColorRed, hairColorGreen, hairColorBlue);
            }
            else
            {
                HairColor = Config.RandomHairColor ? GetRandomHairColor() : GetHairColorForSkin(SkinColor);
            }

            //Set Body Type
            BodyType = crewMember.LoadBelief(NPCBelief.AvatarBodyType) ?? $"Body{_gender}_{_bodyType}";

            //Set Hair Type
            HairType = crewMember.LoadBelief(NPCBelief.AvatarHairType) ?? $"Hair{StaticRandom.Int(1, Config.HairTypesCount + 1):00}{_gender}";

            //Set Eye Type
            EyeType = crewMember.LoadBelief(NPCBelief.AvatarEyeType) ?? $"Eye{_gender}_{_bestSkill}";

            //Set Eye Color
            var textEyeColor = crewMember.LoadBelief(NPCBelief.AvatarEyeColor);

            if (textEyeColor != null)
            {
                EyeColor = GetEyeColorFromText(textEyeColor);
            }
            else
            {
                if (byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarEyeColorRed), out var eyeColorRed) &&
                    byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarEyeColorGreen), out var eyeColorGreen) &&
                    byte.TryParse(crewMember.LoadBelief(NPCBelief.AvatarEyeColorBlue), out var eyeColorBlue))
                {
                    EyeColor = new Color(eyeColorRed, eyeColorGreen, eyeColorBlue);
                }
                else
                {
                    EyeColor = GetRandomEyeColor();
                }
            }

            //Set Face type
            EyebrowType = crewMember.LoadBelief(NPCBelief.AvatarEyebrowType) ?? $"Face{_gender}_{_bestSkill}_Eyebrows";
            NoseType    = crewMember.LoadBelief(NPCBelief.AvatarNoseType) ?? $"Face{_gender}_{_bestSkill}_Nose";

            //Specify the teeth for male avatars
            if (IsMale)
            {
                TeethType = crewMember.LoadBelief(NPCBelief.AvatarTeethType) ?? $"Face{_gender}_{_bestSkill}_Teeth";
            }

            //Set Mouth Type
            MouthType = crewMember.LoadBelief(NPCBelief.AvatarMouthType) ?? $"Face{_gender}_{_bestSkill}_Mouth";

            // Set Height and Width (Weight)
            if (float.TryParse(crewMember.LoadBelief(NPCBelief.AvatarHeight), out var loadedHeight))
            {
                Height = loadedHeight;
            }
            else
            {
                Height = 1 + StaticRandom.Float(-0.075f, 0.075f);
            }

            if (float.TryParse(crewMember.LoadBelief(NPCBelief.AvatarWeight), out var loadedWeight))
            {
                Weight = loadedWeight;
            }
            else
            {
                Weight = 1 + StaticRandom.Float(-0.075f, 0.075f);
            }

            //Save attributes
            UpdateAvatarBeliefs(crewMember);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Load an existing game
        /// </summary>
        public void LoadGame(string storageLocation, string boatName)
        {
            UnloadGame();
            var valid = CheckIfGameExists(storageLocation, boatName, out var iat);

            if (!valid)
            {
                return;
            }
            EventController = new EventController(iat);
            ValidateGameConfig();
            //get the iat file and all characters for this game
            var characterList = iat.GetAllCharacterSources();
            var crewList      = new List <CrewMember>();
            var nameList      = new List <string>();

            foreach (var character in characterList)
            {
                var rpc      = RolePlayCharacterAsset.LoadFromFile(character.Source);
                var position = rpc.GetBeliefValue(NPCBelief.Position.Description());
                nameList.Add(rpc.BodyName);
                //if this character is the manager, load the game details from this file and set this character as the manager
                if (position == "Manager")
                {
                    var person = new Person(rpc);
                    var boat   = new Boat(person.LoadBelief(NPCBelief.BoatType));
                    var nation = person.LoadBelief(NPCBelief.Nationality);
                    ShowTutorial              = bool.Parse(person.LoadBelief(NPCBelief.ShowTutorial));
                    TutorialStage             = Convert.ToInt32(person.LoadBelief(NPCBelief.TutorialStage));
                    _customTutorialAttributes = new Dictionary <int, Dictionary <string, string> >();
                    QuestionnaireCompleted    = bool.Parse(person.LoadBelief(NPCBelief.QuestionnaireCompleted) ?? "false");
                    Team = new Team(iat, storageLocation, iat.ScenarioName, nation, boat);
                    if (boat.Type == "Finish")
                    {
                        Team.Finished = true;
                    }
                    ActionAllowance          = Convert.ToInt32(person.LoadBelief(NPCBelief.ActionAllowance));
                    CrewEditAllowance        = Convert.ToInt32(person.LoadBelief(NPCBelief.CrewEditAllowance));
                    RaceSessionLength        = ShowTutorial ? ConfigKey.TutorialRaceSessionLength.GetIntValue() : ConfigKey.RaceSessionLength.GetIntValue();
                    Team.TeamColorsPrimary   = new Color(Convert.ToInt32(person.LoadBelief(NPCBelief.TeamColorRedPrimary)), Convert.ToInt32(person.LoadBelief(NPCBelief.TeamColorGreenPrimary)), Convert.ToInt32(person.LoadBelief(NPCBelief.TeamColorBluePrimary)));
                    Team.TeamColorsSecondary = new Color(Convert.ToInt32(person.LoadBelief(NPCBelief.TeamColorRedSecondary)), Convert.ToInt32(person.LoadBelief(NPCBelief.TeamColorGreenSecondary)), Convert.ToInt32(person.LoadBelief(NPCBelief.TeamColorBlueSecondary)));
                    Team.Manager             = person;
                    continue;
                }
                //set up every other character as a CrewManager, making sure to separate retired and recruits
                var crewMember = new CrewMember(rpc);
                switch (position)
                {
                case "Retired":
                    Team.RetiredCrew.Add(crewMember.Name, crewMember);
                    Team.RetiredCrew.Values.ToList().ForEach(cm => cm.LoadBeliefs(nameList));
                    continue;

                case "Recruit":
                    Team.Recruits.Add(crewMember.Name, crewMember);
                    Team.Recruits.Values.ToList().ForEach(cm => cm.LoadBeliefs(nameList));
                    continue;
                }
                crewList.Add(crewMember);
            }
            crewList.ForEach(cm => Team.AddCrewMember(cm));
            crewList.ForEach(cm => cm.LoadBeliefs(nameList, Team));
            LoadLineUpHistory();
            LoadCurrentEvents();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Create a new game
        /// </summary>
        public void NewGame(string storageLocation, string name, Color teamColorsPrimary, Color teamColorsSecondary, string managerName, bool showTutorial, string nation, List <CrewMember> crew = null)
        {
            UnloadGame();
            //create folder and iat file for game
            var combinedStorageLocation = Path.Combine(storageLocation, name);

            Directory.CreateDirectory(combinedStorageLocation);
            //create a copy of the template IntegratedAuthoringTool
            var iat = ConfigStore.IntegratedAuthoringTool.Copy();

            EventController = new EventController(iat);
            ValidateGameConfig();
            //set up boat and team
            var initialType = ConfigStore.GameConfig.PromotionTriggers.First(pt => pt.StartType == "Start").NewType;
            var boat        = new Boat(initialType);

            Team = new Team(iat, storageLocation, name, nation, boat);
            var positionCount = boat.PositionCount;

            Team.TeamColorsPrimary   = teamColorsPrimary;
            Team.TeamColorsSecondary = teamColorsSecondary;
            iat.ScenarioName         = name;
            iat.SetFutureFilePath(Path.Combine(combinedStorageLocation, name + ".iat"));
            //create manager
            var manager = new Person
            {
                Name = managerName
            };

            Team.Manager = manager;
            //create the initial crew members
            var initialCrew = false;

            if (crew == null)
            {
                initialCrew = true;
                for (var i = 0; i < positionCount * 2; i++)
                {
                    var newMember = new CrewMember(boat.GetWeakestPosition(Team.CrewMembers.Values.ToList()), Team.Nationality);
                    Team.UniqueNameCheck(newMember);
                    Team.AddCrewMember(newMember);
                }
            }
            if (!initialCrew)
            {
                crew.ForEach(cm => Team.AddCrewMember(cm));
            }
            //set up initial values
            ActionAllowance           = GetStartingActionAllowance();
            CrewEditAllowance         = GetStartingCrewEditAllowance();
            RaceSessionLength         = showTutorial ? ConfigKey.TutorialRaceSessionLength.GetIntValue() : ConfigKey.RaceSessionLength.GetIntValue();
            CurrentRaceSession        = 0;
            ShowTutorial              = showTutorial;
            TutorialStage             = 0;
            _customTutorialAttributes = new Dictionary <int, Dictionary <string, string> >();
            QuestionnaireCompleted    = false;
            //create manager files and store game attribute details
            manager.CreateFile(iat, combinedStorageLocation);
            manager.UpdateSingleBelief(NPCBelief.Position, "Manager");
            manager.UpdateSingleBelief(NPCBelief.BoatType, boat.Type);
            manager.UpdateSingleBelief(NPCBelief.ShowTutorial, ShowTutorial);
            manager.UpdateSingleBelief(NPCBelief.QuestionnaireCompleted, QuestionnaireCompleted);
            manager.UpdateSingleBelief(NPCBelief.TutorialStage, TutorialStage);
            manager.UpdateSingleBelief(NPCBelief.Nationality, nation);
            manager.UpdateSingleBelief(NPCBelief.ActionAllowance, ActionAllowance);
            manager.UpdateSingleBelief(NPCBelief.CrewEditAllowance, CrewEditAllowance);
            manager.UpdateSingleBelief(NPCBelief.TeamColorRedPrimary, teamColorsPrimary.R);
            manager.UpdateSingleBelief(NPCBelief.TeamColorGreenPrimary, teamColorsPrimary.G);
            manager.UpdateSingleBelief(NPCBelief.TeamColorBluePrimary, teamColorsPrimary.B);
            manager.UpdateSingleBelief(NPCBelief.TeamColorRedSecondary, teamColorsSecondary.R);
            manager.UpdateSingleBelief(NPCBelief.TeamColorGreenSecondary, teamColorsSecondary.G);
            manager.UpdateSingleBelief(NPCBelief.TeamColorBlueSecondary, teamColorsSecondary.B);
            manager.SaveStatus();

            var names = Team.CrewMembers.Keys.ToList();

            names.Add(managerName);

            //set up files and details for each CrewMember
            foreach (var member in Team.CrewMembers.Values)
            {
                member.CreateTeamMemberFile(iat, combinedStorageLocation, names, Team.TeamColorsPrimary, Team.TeamColorsSecondary, initialCrew);
            }
            Team.CreateRecruits();
        }