private void UpdateAllOnStart(IParty party, IAdventure adventure) { foreach (var o in observers) { o.UpdateOnStart(party, adventure); } }
public string QueueIgnoringRequirements(IParty party) { Unqueue(party); int minLevel = PartyUtils.GetLowestLevelPlayer(party).Level; IList <IAdventure> adventures = repository .Get(a => { return(a.MinimumLevel <= minLevel && AdventureUtils.GetCostRequirementPredicate(party).Invoke(a)); }); if (adventures.Count == 0) { return("A member in your party is either too low a level or cannot afford, " + "and dungeons!"); } Random rnd = new Random(); IAdventure adventure = adventures[rnd.Next(0, adventures.Count - 1)]; adventureQueue.Add(new KeyValuePair <IParty, IAdventure>(party, adventure)); return(string.Format("Your party has joined the adventure queue for {0}, which " + "will start shortly. Maximum level requirements have been ignored, Xp is capped at " + "the adventures maximum level ({1}). ", adventure.Name, adventure.MaximumLevel)); }
public static Func <IAdventure, bool> GetCostRequirementPredicate(IParty party) { return(new Func <IAdventure, bool>(a => { IAdventure adventure = a; return party.Players.All(p => { return adventure.Cost <= p.Coins; }); })); }
private int CalcXP(IAdventure adventure, IParty party, float rewardMod) { int level = party.Level < adventure.MaximumLevel ? party.Level : adventure.MaximumLevel; int totalLevelTNL = new LevelFactory().createFromLevel(100, level).TNL(); int xp = totalLevelTNL / 50; return(ScaleReward(level, xp, rewardMod)); }
private string Penalise(IParty party, IAdventure adventure) { int xp = CalcXP(adventure, party, adventure.RewardModifier); int coins = CalcXP(adventure, party, adventure.RewardModifier); string message = "Failed to complete " + adventure.Name + "! "; return(message); }
private int CalcCoins(IAdventure adventure, IParty party, float rewardMod) { int coins = 50; //base default from legacy coins += (party.CoinBonus * coins) / 100; int level = party.Level < adventure.MaximumLevel ? party.Level : adventure.MaximumLevel; return(ScaleReward(level, coins, rewardMod) / party.Players.Count); }
private bool isEncounterSuccessful(IParty party, IAdventure adventure, int encounter) { float chance = party.SuccessChance * (party.Level / adventure.MaximumLevel); chance = chance < (party.SuccessChance * .75) ? party.SuccessChance * .75f : chance; chance += adventure.BaseSuccessRate * (party.Players.Count / PartySizeLimit); chance -= adventure.EncounterDifficulty(encounter); return(chance > random.Next(0, 100)); }
private string Reward(IParty party, IAdventure adventure) { int xp = CalcXP(adventure, party, adventure.RewardModifier); int coins = CalcCoins(adventure, party, adventure.RewardModifier); string rewardMessage = adventure.Name + " has been completed! Each player has been awarded: " + xp + " xp and " + coins + " coins! "; party.AddXp(xp); party.AddCoins(coins); return(rewardMessage); }
static void Main(string[] args) { Console.WriteLine("工廠模式"); List <ITrainingCamp> trainCamps = new List <ITrainingCamp>() { new ArcherTrainCamp(), new WarriorTrainCamp() }; foreach (ITrainingCamp trainCamp in trainCamps) { IAdventure adventure = trainCamp.TrainAdventure(); adventure.ShowType(); } }
//Gets a new AdventureRepository, this repository will look up the dungeonlist.ini file and use // it as a bridge to find the correct file for each type of dungeon. // If this method is called more than once during the application life, it will check if the // dungeons have already been loaded before doing so again. // Params: // dbfp - dungeonBridgeFilePath [Legacy - "content/dungeonlist.ini"] // dfpp - dungeonFilePathPrefix [Legacy - "content/dungeons/"] // throws: // IOException - if a file cannot be accessed this exception will be thrown // NullPointException - Is thrown if any params are null or any resulting calls to files return null. public static LegacyAdventureRepository getInstance(string bridgeFile, string filePrefix, IEquipmentRepository items) { if (LegacyAdventureRepository.ADVENTURES != null) { return(new LegacyAdventureRepository(LegacyAdventureRepository.ADVENTURES)); } IDictionary <int, string> dungeonDic = createDungeonID_File_Dic(bridgeFile, filePrefix); IDictionary <int, IAdventure> adventures = new Dictionary <int, IAdventure>(); foreach (KeyValuePair <int, string> dungeonID_FilePath in dungeonDic) { IAdventure adv = create(dungeonID_FilePath, items); adventures.Add(adv.ID, adv); } return(new LegacyAdventureRepository(adventures)); }
private void FormAdventurePartyAndRemoveTickets(IAdventure adventure, params AdventureTicket[] partyTickets) { IList <IPlayer> players = new List <IPlayer>(); foreach (var ticket in partyTickets) { foreach (var p in ticket.Players) { players.Add(p); } tickets.Remove(ticket.TimeIn); waitTimes.Add(TimeSpan.FromSeconds(DateTime.Now.Second / ticket.TimeIn.Second)); } IParty party = pool.Create(players); adventureQueue.Add(new KeyValuePair <IParty, IAdventure>(party, adventure)); }
private string Queue(IParty party, IList <IAdventure> adventures) { if (adventures.Any(AdventureUtils.GetPartySizeRequirementPredicate(party))) { IEnumerable <IAdventure> matches = adventures .Where(AdventureUtils.GetPartySizeRequirementPredicate(party)); Random rnd = new Random(); IAdventure adventure = matches.ElementAt(rnd.Next(0, matches.Count())); adventureQueue.Add(new KeyValuePair <IParty, IAdventure>(party, adventure)); return(string.Format("Your party has joined the adventure queue for {0}, which " + "will start shortly.", adventure.Name)); } var ticket = new AdventureTicket(adventures, party.Players.ToArray()); tickets.Add(ticket.TimeIn, ticket); TryToBuildParty(); return(string.Format("You have joined the group finder! The estimated " + "waiting time is {0} mins", GetAverageWaitTime().Minutes)); }
/// <summary> /// This function will roll chances against the party's Item Find stat, if successful /// then the item will be randomly given to a player in the party. The player /// does not need to meet any requirements to use the item in order for it to drop /// for them. /// The item is then placed in the players inventory and the resulting dictionary is /// returned to show what items have been rewarded and who to. /// </summary> /// <param name="party"></param> /// <param name="adventure"></param> /// <returns></returns> private IDictionary <IPlayer, IList <IItem> > RewardItems(IParty party, IAdventure adventure) { IDictionary <IPlayer, IList <IItem> > items = new Dictionary <IPlayer, IList <IItem> >(); foreach (var item in adventure.Loot) { if (party.ItemFind >= random.Next(100)) { IPlayer player = party.Players[random.Next(0, party.Players.Count)]; player.AddItem(item); if (items.ContainsKey(player)) { items[player].Add(item); } else { items.Add(player, new List <IItem>(new IItem[] { item })); } } } return(items); }
public string QueueIgnoringRequirements(IParty party, int[] ids) { Unqueue(party); int minLevel = PartyUtils.GetLowestLevelPlayer(party).Level; IList <IAdventure> adventures = repository.Get(a => { return(ids.Contains(a.ID) && a.MinimumLevel < minLevel); }); if (adventures.Count == 0) { return("A member in your party is too low a level to Queue."); } Random rnd = new Random(); IAdventure adventure = adventures[rnd.Next(0, adventures.Count - 1)]; adventureQueue.Add(new KeyValuePair <IParty, IAdventure>(party, adventure)); return(string.Format("Your party has joined the adventure queue for {0}, which " + "will start shortly. Maximum level requirements have been ignored.", adventure.Name)); }
public int CompareTo(IAdventure other) { return(this.MinimumLevel.CompareTo(other.MinimumLevel)); }
public EReturnCode GoOnAdventure(IAdventure _adventure) { throw new NotImplementedException(); }