public Party Add(Party item) { if (item == null) throw new ArgumentNullException("Party is null"); using (Context con = new Context()) { foreach (var ing in item.Menus) { if (con.Menu.FirstOrDefault(x => x.Id == ing.Id) == null) throw new ArgumentException("You need to add the menu to the database first: " + ing.Name); if (!con.Menu.FirstOrDefault(x => x.Id == ing.Id).Equals(ing)) throw new ArgumentException("You need to update the menu first: " + ing.Name); } if (con.Address.FirstOrDefault(x => x.Id == item.Address.Id) == null) throw new ArgumentException("You need to add the address to the database first: " + item.Address.StreetAddress); if (!con.Address.FirstOrDefault(x => x.Id == item.Address.Id).Equals(item.Address)) throw new ArgumentException("You need to update the address first: " + item.Address.StreetAddress); if (con.Customer.FirstOrDefault(x => x.Id == item.Customer.Id) == null) throw new ArgumentException("You need to add the customer to the database first: " + item.Customer.FirstName); if (!con.Customer.FirstOrDefault(x => x.Id == item.Customer.Id).Equals(item.Customer)) throw new ArgumentException("You need to update the customer first: " + item.Customer.FirstName); } using (Context con = new Context()) { item.Menus.ForEach(x => con.Menu.Find(x.Id)); con.Address.Attach(item.Address); con.Customer.Attach(item.Customer); item = con.Party.Add(item); con.SaveChanges(); } return item; }
public static void AddToParty(FighterData fighter, Party party) { // TODO: party capacity get. if ((party.currentCost + fighter.cost) < GameData.instance.playerData.partyCapacity) { party.Add (fighter); } }
public static void CreateBook(string parent, string bookName, string strategy, string portfolio) { try { var exist = Env.Current.StaticData.GetPartyByCode(bookName); if (exist != null) { throw new Exception(String.Format("Book {0} already exists!", bookName)); } else { var entity = Env.Current.StaticData.GetPartyByCode(parent); if (entity == null) { throw new Exception("Cannot find entity" + entity); } var newStrategy = new Party { Code = bookName, Name = bookName, ParentId = entity.Id, Role = Party.Book, Description = "Legacy strategy" }; newStrategy.SetProperty("Portfolio", portfolio); newStrategy.SetProperty("Strategy", strategy); Env.Current.StaticData.SaveParty(newStrategy); ScriptBase.Logger.InfoFormat("Created book {0} in pfolio {1}.", bookName, portfolio); } } catch (Exception ex) { ScriptBase.Logger.Error(ex); } }
public Overworld(Party playerParty, Area area) { if (playerParty == null) throw new Exception("Party playerParty cannot be null"); PlayerParty = playerParty; Area = area; EnemyParties = new List<Party>(); states = new Stack<OverworldState>(); states.Push(new OverworldStates.Menu(this)); stateChanged = true; Map = new Map(100, 100, 5, 5); PlayerParty.PrimaryPartyMember.StartOverworld(new Vector2(200.0f)); addEntity(PlayerParty.PrimaryPartyMember.OverworldEntity); camera = new Camera(Game1.ScreenSize); camera.Target = playerParty.PrimaryPartyMember.OverworldEntity; //populateWithScenery(); //populateWithEnemies(); playerInvincibilityTimer = 0.0f; }
public Party CreateParty(string userId, string title, string description, double longitude, double latidude, string locationAddress, DateTime startTime, DateTime creationTime) { var party = new Party() { UserId = userId, Title = title, Description = description, Longitude = longitude, Latitude = latidude, LocationAddress = locationAddress, StartTime = startTime, CreationTime = creationTime }; var user = this.users .All() .Where(u => u.Id == userId) .FirstOrDefault(); this.parties.Add(party); party.Members.Add(user); user.Parties.Add(party); this.users.SaveChanges(); return party; }
public ProductPurchasePrice PurchasePrice(Party supplier, DateTime orderDate, Product product = null, Part part = null) { ProductPurchasePrice purchasePrice = null; foreach (SupplierOffering supplierOffering in supplier.SupplierOfferingsWhereSupplier) { if ((supplierOffering.ExistProduct && supplierOffering.Product.Equals(product)) || (supplierOffering.ExistPart && supplierOffering.Part.Equals(part))) { if (supplierOffering.FromDate <= orderDate && (!supplierOffering.ExistThroughDate || supplierOffering.ThroughDate >= orderDate)) { foreach (ProductPurchasePrice productPurchasePrice in supplierOffering.ProductPurchasePrices) { if (productPurchasePrice.FromDate <= orderDate && (!productPurchasePrice.ExistThroughDate || productPurchasePrice.ThroughDate >= orderDate)) { purchasePrice = productPurchasePrice; break; } } } } if (purchasePrice != null) { break; } } return purchasePrice; }
public BattleInfo(BattleType battleType, Party party1, Party party2) { _BattleType = battleType; _ParticipatingParties = new List<Party>(); _ParticipatingParties.Add(party1); _ParticipatingParties.Add(party2); }
public void AddAccountability(Party parent,Party child) { Guard.Against<ArgumentNullException>(_partyHierarchyRepository == null, "建構式需指定repository"); PartyHierarchy partyHierarchy = new PartyHierarchy() { Level = 1, ParentPartyId = parent.Id, ChildPartyId = child.Id, PartyHierarchyType = PartyHierarchyType.Accountable }; _partyHierarchyRepository.SaveOrUpdate(partyHierarchy); IList<PartyHierarchy> allParents = _partyHierarchyRepository. Query(q => q.ChildPartyId == parent.Id && q.PartyHierarchyType == PartyHierarchyType.Accountable); foreach(var up in allParents) { PartyHierarchy hierarchy = new PartyHierarchy() { Level = up.Level + 1, ParentPartyId = up.ParentPartyId, ChildPartyId = child.Id, PartyHierarchyType = up.PartyHierarchyType }; _partyHierarchyRepository.SaveOrUpdate(hierarchy); } }
void recieveCurrentParty(PhotonPlayer[] _players, bool _open) { List<PhotonPlayer> _players2 = new List<PhotonPlayer>(); foreach (PhotonPlayer _p in _players) { _players2.Add(_p); } Party _party = new Party(_players2, _open); GameObject.FindGameObjectWithTag("MenuController").GetComponentInChildren<SocialScreen>().recieveCurrentParty(_party); }
public EncounterIntro(Overworld overworld, Party enemyParty) : base(overworld) { if (enemyParty == null) throw new Exception("Party enemyParty cannot be null"); this.enemyParty = enemyParty; }
public static void run() { string answer; bool success = false; Party p1 = new Party(true), p2 = new Party(); do { if (success) { heal(p1); } else { p1 = initPlayerParty(); } success = fight(p1, p2); Console.WriteLine("\nGo another round? (y/n)"); answer = Console.ReadLine().ToLower(); Console.WriteLine(); } while (answer.Equals("y")); Console.Write("Until the next time!"); Text.userRead(); }
public static void HandlePartyInvitationDungeonRequest(PartyInvitationDungeonRequestMessage message, WorldClient client) { WorldClient target = WorldServer.Instance.GetOnlineClient(message.name); Party p; if (client.Character.PartyMember == null) { WorldServer.Instance.Parties.OrderBy(x => x.Id); int partyId = 0; if (WorldServer.Instance.Parties.Count > 0) { partyId = WorldServer.Instance.Parties.Last().Id + 1; } else { partyId = 1; } p = new Party(partyId, client.Character.Id, ""); } else { p = WorldServer.Instance.Parties.Find(x => x.Id == client.Character.PartyMember.Party.Id); } if (p == null) return; p.SetName(DungeonsIdRecord.DungeonsId.Find(x => x.Id == message.dungeonId).Name, client); p.CreateInvitation(client, target, PartyTypeEnum.PARTY_TYPE_DUNGEON, message.dungeonId); if (p.Members.Count == 0) { p.BossCharacterId = client.Character.Id; p.NewMember(client); } }
public override double AbilityModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory, Ability ability) { if (weapon != null && weapon.Category == SchemaConstants.EquipmentCategory.Sword && ability.Formula == SchemaConstants.Formulas.Physical) { return 1.1; } return 1.0; }
public override double AbilityModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory, Ability ability) { if (weapon != null && weapon.Category == SchemaConstants.EquipmentCategory.Bow && ability.Category == SchemaConstants.AbilityCategory.BlackMagic) { return 1.2; } return 1.0; }
public override double AbilityModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory, Ability ability) { if (ability.Element == SchemaConstants.ElementID.Dark && ability.Formula != SchemaConstants.Formulas.Healing) { return 1.2; } return 1.0; }
public Encounter(Overworld overworld, Party enemyParty) : base(overworld) { this.enemyParty = enemyParty; // In here instead of Start() to stop flicker when the state is rendered before Start() is called. The EncounterRenderer doesn't rely on the state of Encounter anyway OverworldStateRenderer = new EncounterRenderer(this); }
public override double AbilityModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory, Ability ability) { if (ability.Element == SchemaConstants.ElementID.Fire) { return 1.1; } return 1.0; }
public override double AbilityModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory, Ability ability) { if (ability.Category == SchemaConstants.AbilityCategory.Thief) { return 1.3; } return 1.0; }
public override double AbilityModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory, Ability ability) { if (ability.IsJumpAttack()) { return 1.25; } return 1.0; }
public override double DefModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory) { if (armor != null && armor.Category == SchemaConstants.EquipmentCategory.Armor) { return 1.1; } return 1.0; }
public override double MagModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory) { if (weapon != null && weapon.Category == SchemaConstants.EquipmentCategory.Gun) { return 1.1; } return 1.0; }
public override double AbilityModifier(Party.DataEquipmentInformation weapon, Party.DataEquipmentInformation armor, Party.DataEquipmentInformation accessory, Ability ability) { if (ability.Category == SchemaConstants.AbilityCategory.WhiteMagic && ability.Formula != SchemaConstants.Formulas.Healing) { return 1.2; } return 1.0; }
public IList<Entity> GetAllEntityFor(Party party,Operation operation) { //假如IsParty為真,取得Party的所有下層 //假如IsParty為否,必須取得歸屬的組織,再找到Party所有下層 //或該Party已經有下層,也要取出 //取得這個Party參予的Organization //用找出來的Party + Org去撈Permission return null; }
public void EnterCombatMap(Party side1, Party side2) { _side1 = side1; _side2 = side2; unitsSide1 = side1.units; unitsSide2 = side2.units; persistentWorldMap.SetActive(false); Application.LoadLevel(1); }
public ActionResult CreatePartial(Party obj) { if(Request.IsAjaxRequest()) { dataManager.Parties.Save(obj); return Json(new { Name = obj.Name, Id = obj.Id, Key = "PartyId" }, JsonRequestBehavior.AllowGet); } return Json("", JsonRequestBehavior.AllowGet); }
public static NpcMover Create(OverworldMovementType movementType, Party party, Party playerParty, Overworld overworld) { switch (movementType) { case OverworldMovementType.Wander: return new Wander(party, overworld); case OverworldMovementType.Follow: return new Follow(party, playerParty, overworld); case OverworldMovementType.Run: return new Run(party, playerParty, overworld); default: return null; } }
void Awake() { S = this; //party = new Pokemon[6]; int i = 0; print (Player.S.party [0].Name); foreach (Pokemon poke in Player.S.party) { party[i] = poke; ++i; } }
public void CreatePermissionForParty(Party party,Entity entity,Operation operation) { Permission permission = new Permission() { Party = party, Entity = entity, Operation = operation, Level = 0 }; _permissionRepository.SaveOrUpdate(permission); }
public Battle(Party playerParty, Party enemyParty, Encounter overworldEncounter) { if (playerParty == null) throw new Exception("Party playerParty cannot be null"); if (enemyParty == null) throw new Exception("Party enemyParty cannot be null"); PlayerParty = playerParty.Tap(party => party.StartBattle(this)); EnemyParty = enemyParty.Tap(party => party.StartBattle(this)); states = new Stack<BattleState>(); states.Push(new BattleStates.Intro(this)); stateChanged = true; OverworldEncounter = overworldEncounter; Camera = new Camera(Game1.ScreenSize); Camera.Position = Camera.Size / 2.0f; cameraUpdateDelay = 0.0f; RepositionPartyMembers(); updateCamera(); Camera.Scale = Camera.TargetScale; updateCamera(); Camera.Position = Camera.TargetPosition; generateBackground(); generateBackgroundScenery(); generateFloorScenery(); whitePixelTextureData = ResourceManager.GetTextureData("white_pixel"); arrowTextureData = ResourceManager.GetTextureData("arrow_down"); CharacterClassHeadTextureData = new Dictionary<CharacterClass, TextureData> { { CharacterClass.Warrior, ResourceManager.GetTextureData("battle_ui/warrior_head") }, { CharacterClass.Marksman, ResourceManager.GetTextureData("battle_ui/marksman_head") }, { CharacterClass.Medic, ResourceManager.GetTextureData("battle_ui/medic_head") }, { CharacterClass.Thief, ResourceManager.GetTextureData("battle_ui/thief_head") } }; keyboardButtonTextureData = ResourceManager.GetTextureData("battle_ui/buttons/key"); gamepadButtonTextureData = new Dictionary<InputButton, TextureData> { { InputButton.A, ResourceManager.GetTextureData("battle_ui/buttons/gamepad_a") }, { InputButton.B, ResourceManager.GetTextureData("battle_ui/buttons/gamepad_b") }, { InputButton.LeftTrigger, ResourceManager.GetTextureData("battle_ui/buttons/gamepad_lt") } }; BorderTextureData = new TextureData[Directions.Length]; for (int i = 0; i < Directions.Length; ++i) BorderTextureData[i] = ResourceManager.GetTextureData("battle_ui/borders/" + Directions[i]); PlayerPartyItemsUsed = 0; LastUsedThinkActionTypes = new ConditionalWeakTable<PartyMember, Wrapper<BattleStates.ThinkActionType>>(); }
public void StoreEnemy() { Party.SetEnemy(enemy); }
public static Person ReconstructPerson(Party party, Person person) { person.DisplayName = party.DisplayName; return(person); }
public void GetPlayer() { player = Party.GetPlayer(); }
public async Task <List <OfferApplication> > GetAppsForExposureRelatedGroups(string customerNumber, Party involvedParty, List <OfferApplication> otherApplications, List <ApplicationStatus> statusesList, List <PartyRole> rolesList, List <string> listOfCalcParties) { var exposureRelatedGroups = _configurationService.GetEffective <List <string> >("offer/exposure-related-groups", "ownership").Result; if (!listOfCalcParties.Contains(involvedParty.CustomerNumber)) { listOfCalcParties.Add(involvedParty.CustomerNumber); if (involvedParty.PartyKind == PartyKind.Organization) { var org = (OrganizationParty)involvedParty; var relatedParties = org.Relationships != null?org.Relationships.Where(r => exposureRelatedGroups.Contains(r.Kind) && !listOfCalcParties.Contains(r.ToParty.Number)).ToList() : null; otherApplications.AddRange(_applicationRepository.CheckExistingOffersForCustomer(customerNumber, statusesList, rolesList)); if (relatedParties != null) { foreach (var relatedParty in relatedParties) { if (!listOfCalcParties.Contains(relatedParty.ToParty.Number)) { // listOfCalcParties.Add(relatedParty.ToParty.Number); if (relatedParty.ToParty.Kind == PartyKind.Individual) { //existing customer Party partyorg = new IndividualParty { CustomerNumber = relatedParty.ToParty.Number, PartyKind = relatedParty.ToParty.Kind }; var inparty = await _masterPartyDataService.GetPartyData(partyorg); await GetAppsForExposureRelatedGroups(relatedParty.ToParty.Number, inparty, otherApplications, statusesList, rolesList, listOfCalcParties); // otherApplications.AddRange(_applicationRepository.CheckExistingOffersForCustomer(relatedParty.ToParty.Number, statusesList, rolesList)); } else { Party partyorg = new OrganizationParty { CustomerNumber = relatedParty.ToParty.Number, PartyKind = relatedParty.ToParty.Kind }; var orgparty = await _masterPartyDataService.GetPartyData(partyorg); await GetAppsForExposureRelatedGroups(relatedParty.ToParty.Number, orgparty, otherApplications, statusesList, rolesList, listOfCalcParties); } } } } } else { var org = (IndividualParty)involvedParty; var relatedParties = org.Relationships != null?org.Relationships.Where(r => exposureRelatedGroups.Contains(r.Kind) && !listOfCalcParties.Contains(r.ToParty.Number)).ToList() : null; otherApplications.AddRange(_applicationRepository.CheckExistingOffersForCustomer(customerNumber, statusesList, rolesList)); if (relatedParties != null) { foreach (var relatedParty in relatedParties) { if (!listOfCalcParties.Contains(relatedParty.ToParty.Number)) { // listOfCalcParties.Add(relatedParty.ToParty.Number); if (relatedParty.ToParty.Kind == PartyKind.Individual) { Party partyin = new IndividualParty { CustomerNumber = relatedParty.ToParty.Number, PartyKind = relatedParty.ToParty.Kind }; var inparty = await _masterPartyDataService.GetPartyData(partyin); await GetAppsForExposureRelatedGroups(relatedParty.ToParty.Number, inparty, otherApplications, statusesList, rolesList, listOfCalcParties); // otherApplications.AddRange(_applicationRepository.CheckExistingOffersForCustomer(relatedParty.ToParty.Number, statusesList, rolesList)); } else { Party partyorg = new OrganizationParty { CustomerNumber = relatedParty.ToParty.Number, PartyKind = relatedParty.ToParty.Kind }; var orgparty = await _masterPartyDataService.GetPartyData(partyorg); await GetAppsForExposureRelatedGroups(relatedParty.ToParty.Number, orgparty, otherApplications, statusesList, rolesList, listOfCalcParties); } } } } } } return(otherApplications); }
internal static Person ReConstructPerson(Party party, Person person) { throw new NotImplementedException(); }
public void StorePlayer() { Party.SetPlayer(player); }
public async Task <ServiceResponse <string> > Register(UserRegisterDto user) { var response = new ServiceResponse <string>(); try { if (await UserExists(user.Username)) { response.Success = false; response.Message = "User already exists."; return(response); } CreatePasswordHash(user.Password, out byte[] passwordHash, out byte[] passwordSalt); //create new party var party = new Party { //create new guid Uuid = Guid.NewGuid().ToString().ToUpper(), CreateDate = DateTime.UtcNow, LastUpdateTimestamp = DateTime.UtcNow }; await context.Party.AddAsync(party); //save to get the party id await context.SaveChangesAsync(); //create person var person = new Person { PersonId = party.PartyId, FullName = user.FullName, PlatformUserName = user.Username, LastUpdateTimestamp = DateTime.UtcNow }; await context.Person.AddAsync(person); //save to get the person id await context.SaveChangesAsync(); //create person as user var actorType = ActorType.Owner; var participantType = await context.PlatformParticipantType .Where(x => x.ParticipantTypeIndicator == actorType.GetDescription()).FirstOrDefaultAsync(); var personAsUser = new PersonAsUser { PersonFk = person.PersonId, Uuid = Guid.NewGuid().ToString().ToUpper(), MobileBusinessFk = null, PasswordBin = passwordHash, PasswordSalt = passwordSalt, PlatformParticipantTypeFk = participantType.PlatformParticipantTypeId, LastUpdateTimestamp = DateTime.UtcNow }; await context.PersonAsUser.AddAsync(personAsUser); //save to get the person as user id await context.SaveChangesAsync(); //save the person id var personId = (int)person.PersonId; //create new contact mechanism uuid var cm = new ContactMechanism() { Uuid = Guid.NewGuid().ToString(), LastUpdateTimestamp = DateTime.UtcNow }; await context.ContactMechanism.AddAsync(cm); //need to save here to get the contact mechanism id!! await context.SaveChangesAsync(); //create Email Address var email = new EmailAddress() { EmailAddressId = cm.ContactMechanismId, Email = user.Username, EmailTypeCode = user.EmailTypeCode ?? "P", LastUpdateTimestamp = DateTime.UtcNow }; await context.EmailAddress.AddAsync(email); await context.SaveChangesAsync(); response.Data = $"User {person.PlatformUserName} created."; } catch (Exception ex) { //create user friendly exception response.Success = false; response.Message = ex.Message; response.Exception = new PlatformScreenException(ex); } return(response); }
public bool DoesCitizenBelongToParty(Citizen citizen, Party party) { return(citizen.PartyMember != null && citizen.PartyMember.PartyID == party.ID); }
public ProtocolFactory(Party me, Quorum quorum) { Me = me; Quorum = quorum; }
public void NextTurn(bool isEnemy) { sprites.GetComponent <CharSprites>().UnfreezeAll(); if (Party.playerCount == 0 || !Party.members[0].GetAlive()) { return; } if (isEnemy) { statusBars.transform.Find("Player Status").GetComponent <StatusBarP>().Check(); statusBars.transform.Find("Enemy Status").GetComponent <StatusBarE>().Check(); TimedMethod[] statuses; for (int i = 0; i < 4; i++) { if (i == Party.enemySlot - 1) { statuses = Party.enemies[i].status.CheckLead(); } else if (Party.enemies[i] != null && Party.enemies[i].GetAlive()) { statuses = Party.enemies[i].status.Check(); } else { statuses = new TimedMethod[0]; } foreach (TimedMethod t in statuses) { methodQueue.Enqueue(t); } } GetEnemy(); if (enemy.GetAlive()) { TimedMethod[] moves = Party.GetEnemy().EnemyTurn(); foreach (TimedMethod move in moves) { methodQueue.Enqueue(move); } } methodQueue.Enqueue(new TimedMethod(0, "NextTurn", new object[] { false })); } else { if (running) { if (Party.GetPlayer().GetGooped() || Party.GetPlayer().GetAsleep() || Party.GetPlayer().GetStunned()) { messageLog.SendMessage("SetMessage", "You can't escape in this condition!"); delay += 60; running = false; } else { Flee(); return; } } Queue <TimedMethod> moves = Party.CheckPassives(); foreach (TimedMethod t in moves) { methodQueue.Enqueue(t); } methodQueue.Enqueue(new TimedMethod("StatusCheck")); } }
public override TimedMethod[] Use() { Attacks.SetAudio("Knife", 30); TimedMethod[] blindPart; if (Party.GetPlayer().GetAccuracy() > Party.GetEnemy().GetEvasion()) { blindPart = Party.GetEnemy().status.Blind(7); } else { blindPart = new TimedMethod[] { new TimedMethod("Null"), new TimedMethod("Null") }; } TimedMethod[] attackPart = new TimedMethod[] { new TimedMethod(0, "Audio", new object[] { "Small Swing" }), new TimedMethod(0, "StagnantAttack", new object[] { true, Party.GetPlayer().GetStrength(), Party.GetPlayer().GetStrength() + 2, Party.GetPlayer().GetAccuracy(), true, true, false }) }; TimedMethod[] total = new TimedMethod[4]; attackPart.CopyTo(total, 0); blindPart.CopyTo(total, 2); return(total); }
public static IList <Constituency> GetConstituencies(Election electionToPredict, bool includeEnglandWales, bool includeScotland) { dynamic loadedJson; using (StreamReader r = new StreamReader(constuencyDataPath)) { string json = r.ReadToEnd(); //List<Item> items = JsonConvert.DeserializeObject<List<Item>>(json); loadedJson = JsonConvert.DeserializeObject(json); } var constituencies = loadedJson.constituencies; List <Constituency> constituenciesList = new List <Constituency>(); foreach (var constituency in constituencies) { var c = new Constituency(); var regionString = (string)constituency.region; if (regionString == "Northern Ireland" || (!includeScotland && regionString == "Scotland") || (!includeEnglandWales && regionString != "Scotland")) { continue; // ignore NI } c.Region = GetRegionFromString(regionString); c.Name = (string)constituency.name; c.ONSReference = (string)constituency.onsRef; var euRef = constituency.referendums.eu; c.ReferendumResults = new Dictionary <ReferendumResult, double> { { ReferendumResult.Leave, (double)euRef.leave }, { ReferendumResult.Remain, (double)euRef.remain } }; var electionResult = electionToPredict == Election.e2017 ? constituency.elections["2015"] : constituency.elections["2017"]; c.PreviousVote = new Dictionary <Party, double>(); foreach (var result in electionResult) { Party party = GetPartyFromString((string)result.Name); double value = (double)result.Value; if (party == Party.Other && c.PreviousVote.ContainsKey(Party.Other)) { c.PreviousVote[party] = c.PreviousVote[party] + value; } else { c.PreviousVote.Add(party, value); } } if (electionToPredict == Election.e2017) { var actualResults = new Dictionary <Party, double>(); foreach (var result in constituency.elections["2017"]) { Party party = GetPartyFromString((string)result.Name); double value = (double)result.Value; if (party == Party.Other && actualResults.ContainsKey(Party.Other)) { actualResults[party] = actualResults[party] + value; } else { actualResults.Add(party, value); } } c.ActualWinner = actualResults.OrderByDescending(r => r.Value).First().Key; } c.Ages = new Dictionary <AgeGroup, double>(); foreach (var result in constituency.age) { AgeGroup age = (AgeGroup)Enum.Parse(typeof(AgeGroup), (string)result.Name); c.Ages.Add(age, (double)result.Value); } c.SocialGrades = new Dictionary <SocialGrade, double>(); foreach (var result in constituency.socialGrades) { SocialGrade socialGrade = (SocialGrade)Enum.Parse(typeof(SocialGrade), (string)result.Name); c.SocialGrades.Add(socialGrade, (double)result.Value); } constituenciesList.Add(c); } return(constituenciesList); }
public static int CorpseNotoriety(Mobile source, Corpse target) { if (target.AccessLevel > AccessLevel.VIP) { return(Notoriety.CanBeAttacked); } Body body = (Body)target.Amount; BaseCreature cretOwner = target.Owner as BaseCreature; if (cretOwner != null) { Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } else if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } if (Factions.Settings.Enabled) { Faction srcFaction = Faction.Find(source, true, true); Faction trgFaction = Faction.Find(target.Owner, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) { return(Notoriety.Enemy); } } if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.IsEnemy(source, target.Owner) && source.Map == Faction.Facet) { return(Notoriety.Enemy); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } int actual = Notoriety.CanBeAttacked; if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead))) { actual = Notoriety.Murderer; } if (DateTime.UtcNow >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice)) { return(actual); } Party sourceParty = Party.Get(source); List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source || (sourceParty != null && Party.Get(list[i]) == sourceParty)) { return(actual); } } return(Notoriety.Innocent); } else { if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead))) { return(Notoriety.Murderer); } if (target.Criminal && target.Map != null && ((target.Map.Rules & MapRules.HarmfulRestrictions) == 0)) { return(Notoriety.Criminal); } Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } else if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } Faction srcFaction = Faction.Find(source, true, true); Faction trgFaction = Faction.Find(target.Owner, true, true); if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet) { List <Mobile> secondList = target.Aggressors; for (int i = 0; i < secondList.Count; ++i) { if (secondList[i] == source || secondList[i] is BaseFactionGuard) { return(Notoriety.Enemy); } } } if (target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target.Owner, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } if (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature)) { return(Notoriety.CanBeAttacked); } List <Mobile> list = target.Aggressors; for (int i = 0; i < list.Count; ++i) { if (list[i] == source) { return(Notoriety.CanBeAttacked); } } return(Notoriety.Innocent); } }
public bool CanTryEncounter(Mobile m, EncounterType encounter) { Party p = Party.Get(m); if (p != null && p.Leader != m) { m.SendLocalizedMessage(1156184); // You may not start a Shadowguard encounter while in a party unless you are the party leader. return(false); } if (encounter == EncounterType.Roof) { if (p != null) { for (var index = 0; index < p.Members.Count; index++) { PartyMemberInfo info = p.Members[index]; if (Table == null || !Table.ContainsKey(info.Mobile) || (Table[info.Mobile] & EncounterType.Required) != EncounterType.Required) { m.SendLocalizedMessage(1156249); // All members of your party must complete each of the Shadowguard Towers before attempting the finale. return(false); } } } else if (Table == null || !Table.ContainsKey(m) || (Table[m] & EncounterType.Required) != EncounterType.Required) { m.SendLocalizedMessage(1156196); // You must complete each level of Shadowguard before attempting the Roof. return(false); } } if (p != null) { for (var index = 0; index < p.Members.Count; index++) { PartyMemberInfo info = p.Members[index]; for (var i = 0; i < Encounters.Count; i++) { ShadowguardEncounter enc = Encounters[i]; if (enc.PartyLeader != null) { Party party = Party.Get(enc.PartyLeader); if (enc.PartyLeader == info.Mobile || party != null && party.Contains(info.Mobile)) { m.SendLocalizedMessage(1156189, info.Mobile.Name); // ~1_NAME~ in your party is already attempting to join a Shadowguard encounter. Start a new party without them or wait until they are finished and try again. return(false); } } foreach (Mobile mob in Queue.Keys) { if (mob != null) { Party party = Party.Get(mob); if (mob == info.Mobile || party != null && party.Contains(info.Mobile)) { m.SendLocalizedMessage(1156189, info.Mobile.Name); // ~1_NAME~ in your party is already attempting to join a Shadowguard encounter. Start a new party without them or wait until they are finished and try again. return(false); } } } } } } for (var index = 0; index < Encounters.Count; index++) { ShadowguardEncounter instance = Encounters[index]; if (instance.PartyLeader == m) { return(false); } } return(true); }
public void Battle() { Character[] enemies; if (Time.timeUnit < 10) { enemies = Easy(); } else if (Time.timeUnit < 20) { if (rng.Next(10) < 5) { enemies = Easy(); } else { enemies = Medium(); } } else if (Time.timeUnit < 30) { int seed = rng.Next(10); if (seed < 2) { enemies = Easy(); } else if (seed < 7) { enemies = Medium(); } else { enemies = Hard(); } } else if (Time.timeUnit < 40) { int seed = rng.Next(10); if (seed < 2) { enemies = Medium(); } else if (seed < 7) { enemies = Hard(); } else { enemies = Deadly(); } } else if (Time.timeUnit < 50) { if (rng.Next(10) < 5) { enemies = Hard(); } else { enemies = Deadly(); } } else { enemies = Deadly(); } foreach (Character c in enemies) { Party.AddEnemy(c); } Party.area = "Overworld"; Time.Increment(); SceneManager.LoadScene("Battle"); }
public void unregisterGroupEvent(Party group) { WatingGroups.Remove(group); group.inKolizeum = false; }
public Party getParty(int gameID) { //Make query string query = "spGetParty"; //Obtain Parameters SqlParameter[] parameters = new SqlParameter[1]; parameters[0] = new SqlParameter("gameID", gameID); //Retrieve Data DataSet data = database.downloadCommand(query, parameters); //Make sure the database found the encounter, else return an empty encounter Party party = new Party(); party.GameID = gameID; for (int i = 0; i < data.Tables[0].Rows.Count; i++) { int entityID = (Int32)data.Tables[0].Rows[i]["entityID"]; string name = HttpUtility.HtmlEncode(data.Tables[0].Rows[i]["entityName"].ToString()); if (name.Contains("'")) { name = name.Replace("'", "'"); } string race = HttpUtility.HtmlEncode(data.Tables[0].Rows[i]["race"].ToString()); if (race.Contains("'")) { race = race.Replace("'", "'"); } int armorClass = (Int32)data.Tables[0].Rows[i]["armorClass"]; int currentHP = (Int32)data.Tables[0].Rows[i]["currentHP"]; int maxHP = (Int32)data.Tables[0].Rows[i]["maxHP"]; int partyMemberID = (Int32)data.Tables[0].Rows[i]["partyMemberID"]; int userID = (Int32)data.Tables[0].Rows[i]["userID"]; bool isNPC = (bool)data.Tables[0].Rows[i]["isNpc"]; int passivePerception = (Int32)data.Tables[0].Rows[i]["passivePerception"]; char size = data.Tables[0].Rows[i]["size"].ToString().ElementAtOrDefault(0); PartyMember partyMember = new PartyMember(); partyMember.Name = name; partyMember.EntityID = entityID; partyMember.Race = race; partyMember.GameID = gameID; partyMember.CurrentHP = currentHP; partyMember.MaxHP = maxHP; partyMember.ArmorClass = armorClass; partyMember.Perception = passivePerception; partyMember.Size = size; partyMember.IsNpc = isNPC; partyMember.PartyMemberID = partyMemberID; partyMember.UserID = userID; Color color; if (isNPC) { color = Color.LightGreen; } else { color = Color.LightBlue; } party.PartyMembers.Add(partyMember, color); } return(party); }
public void GetEnemy() { enemy = Party.GetEnemy(); }
/// <summary> /// Checks if a party is allowed to initiate an application based on the applications AllowedPartyTypes /// </summary> /// <param name="party">The party to check</param> /// <param name="partyTypesAllowed">The allowed party types</param> /// <returns>True or false</returns> public static bool IsPartyAllowedToInstantiate(Party party, PartyTypesAllowed partyTypesAllowed) { if (party == null) { return(false); } if (partyTypesAllowed == null || (!partyTypesAllowed.BankruptcyEstate && !partyTypesAllowed.Organization && !partyTypesAllowed.Person && !partyTypesAllowed.SubUnit)) { // if party types not set, all parties are allowed to initiate return(true); } PartyType partyType = party.PartyTypeName; bool isAllowed = false; switch (partyType) { case PartyType.Person: if (partyTypesAllowed.Person == true) { isAllowed = true; } break; case PartyType.Organization: if (partyTypesAllowed.Organization == true) { isAllowed = true; } else if (partyTypesAllowed.BankruptcyEstate == true) { // BankruptcyEstate is a sub group of organization if (party.UnitType != null && BANKRUPTCY_CODE.Equals(party.UnitType.Trim())) { // The org is a BankruptcyEstate, and BankruptcyEstate are allowed to initiate isAllowed = true; } } else if (partyTypesAllowed.SubUnit == true) { // SubUnit is a sub group of organization if (party.UnitType != null && (SUB_UNIT_CODE.Equals(party.UnitType.Trim()) || SUB_UNIT_CODE_AAFY.Equals(party.UnitType.Trim()))) { // The org is a SubUnit, and SubUnits are allowed to initiate isAllowed = true; } } break; case PartyType.SelfIdentified: if (partyTypesAllowed.Person == true) { isAllowed = true; } break; } return(isAllowed); }
protected override void DoRanged(Boolean p_isMagic, Party p_party, Grid p_grid, GridSlot p_startSlot, out Boolean p_isMelee) { p_isMelee = false; }
public static int CorpseNotoriety( Mobile source, Corpse target ) { if( target.AccessLevel > AccessLevel.Player ) return Notoriety.CanBeAttacked; Body body = (Body)target.Amount; BaseCreature cretOwner = target.Owner as BaseCreature; if( cretOwner != null ) { Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); if( sourceGuild != null && targetGuild != null ) { if( sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild) ) return Notoriety.Ally; else if( sourceGuild.IsEnemy(targetGuild) ) return Notoriety.Enemy; } if( CheckHouseFlag(source, target.Owner, target.Location, target.Map) ) return Notoriety.CanBeAttacked; int actual = Notoriety.CanBeAttacked; if( target.Kills >= 5 || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer)) ) actual = Notoriety.Murderer; if( DateTime.Now >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice) ) return actual; Party sourceParty = Party.Get(source); List<Mobile> list = target.Aggressors; for( int i = 0; i < list.Count; ++i ) { if( list[i] == source || (sourceParty != null && Party.Get(list[i]) == sourceParty) ) return actual; } return Notoriety.Innocent; } else { if( target.Kills >= 5 || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer)) ) return Notoriety.Murderer; if( target.Criminal ) return Notoriety.Criminal; Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner); if( sourceGuild != null && targetGuild != null ) { if( sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild) ) return Notoriety.Ally; else if( sourceGuild.IsEnemy(targetGuild) ) return Notoriety.Enemy; } if( target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable ) return Notoriety.CanBeAttacked; if( CheckHouseFlag(source, target.Owner, target.Location, target.Map) ) return Notoriety.CanBeAttacked; if( !(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature) ) return Notoriety.CanBeAttacked; List<Mobile> list = target.Aggressors; for( int i = 0; i < list.Count; ++i ) { if( list[i] == source ) return Notoriety.CanBeAttacked; } return Notoriety.Innocent; } }
public void AttackAll(bool playerTurn, int lower, int upper, int accuracy, bool usesPower) { TimedMethod[] moves; if (playerTurn) { if (!Attacks.EvasionCheck(Party.GetEnemy(), accuracy)) { StagnantAttack(playerTurn, lower, upper, accuracy, usesPower, true, false); } bool[] slots = new bool[] { Party.GetEnemy(0) != null && Party.GetEnemy(0).GetAlive(), Party.GetEnemy(1) != null && Party.GetEnemy(1).GetAlive(), Party.GetEnemy(2) != null && Party.GetEnemy(2).GetAlive(), Party.GetEnemy(3) != null && Party.GetEnemy(3).GetAlive() }; for (int i = 0; i < 4; i++) { if (slots[i]) { moves = Attacks.Attack(player, Party.GetEnemy(i), lower, upper, accuracy, usesPower, false, false); foreach (TimedMethod m in moves) { methodQueue.Enqueue(m); } } } player.SetCharge(0); moves = Party.CheckDeath(); foreach (TimedMethod m in moves) { methodQueue.Enqueue(m); } GetEnemy(); } else { if (!Attacks.EvasionCheck(Party.GetPlayer(), accuracy)) { StagnantAttack(playerTurn, lower, upper, accuracy, usesPower, true, false); } bool[] slots = new bool[] { Party.GetCharacter(0) != null && Party.GetCharacter(0).GetAlive(), Party.GetCharacter(1) != null && Party.GetCharacter(1).GetAlive(), Party.GetCharacter(2) != null && Party.GetCharacter(2).GetAlive(), Party.GetCharacter(3) != null && Party.GetCharacter(0).GetAlive() }; for (int i = 0; i < 4; i++) { if (slots[i]) { moves = Attacks.Attack(enemy, Party.GetCharacter(i), lower, upper, accuracy, usesPower, false, false); foreach (TimedMethod m in moves) { methodQueue.Enqueue(m); } } } enemy.SetCharge(0); moves = Party.CheckDeath(); foreach (TimedMethod m in moves) { methodQueue.Enqueue(m); } GetPlayer(); } }
public async Task Handle_WhenHandlingCommand_ThrowDomainExceptionIfPartyIsNotEmployer(Party party) { // Arrange var apprenticeship = await SetupApprenticeship(party); var command = new ResumeApprenticeshipCommand { ApprenticeshipId = apprenticeship.Id, UserInfo = new UserInfo() }; // Act var exception = Assert.ThrowsAsync <DomainException>(async() => await _handler.Handle(command, new CancellationToken())); // Assert exception.DomainErrors.Should().BeEquivalentTo(new { ErrorMessage = $"Only employers are allowed to edit the end of completed records - {party} is invalid" }); }
void Start() { party = Game.Instance.PlayerParty; cameraContainer = Game.Instance.CameraContainer.transform; party.transform.position = partyPosition; }
public static bool ValidIndirectTarget(Mobile from, Mobile to) { if (from == to) { return(true); } if (to.Hidden && to.AccessLevel > from.AccessLevel) { return(false); } Guild fromGuild = GetGuildFor(from); Guild toGuild = GetGuildFor(to); if (fromGuild != null && toGuild != null && (fromGuild == toGuild || fromGuild.IsAlly(toGuild))) { return(false); } Party p = Party.Get(from); if (p != null && p.Contains(to)) { return(false); } if (to is BaseCreature) { BaseCreature c = (BaseCreature)to; if (c.Controlled || c.Summoned) { if (c.ControlMaster == from || c.SummonMaster == from) { return(false); } if (p != null && (p.Contains(c.ControlMaster) || p.Contains(c.SummonMaster))) { return(false); } } } if (from is BaseCreature) { BaseCreature c = (BaseCreature)from; if (c.Controlled || c.Summoned) { if (c.ControlMaster == to || c.SummonMaster == to) { return(false); } p = Party.Get(to); if (p != null && (p.Contains(c.ControlMaster) || p.Contains(c.SummonMaster))) { return(false); } } } if (to is BaseCreature && !((BaseCreature)to).Controlled && ((BaseCreature)to).InitialInnocent) { return(true); } int noto = Notoriety.Compute(from, to); return(noto != Notoriety.Innocent || from.Kills >= 5); }
/// <summary> /// Opens seleted party with <see cref="PartyPreviewView"/>. /// </summary> /// <param name="sender"></param> /// <param name="o"></param> private void RateParty(object sender, Party o) { PreviewItemSelected <Party, RateView>(o, new object[] { Height, Width }); }
protected override void DoMelee(Boolean p_isMelee, Party p_party, Grid p_grid, GridSlot p_startSlot) { }
public void CheckQueue() { if (Queue.Count == 0) { return; } bool message = false; List <Mobile> copy = new List <Mobile>(Queue.Keys); for (int i = 0; i < copy.Count; i++) { Mobile m = copy[i]; if (m.Map != Map.TerMur || m.NetState == null) { RemoveFromQueue(m); if (i == 0) { message = true; } continue; } for (var index = 0; index < Encounters.Count; index++) { ShadowguardEncounter inst = Encounters[index]; if (inst.PartyLeader == m) { if (i == 0) { message = true; } RemoveFromQueue(m); } } if (Queue.Count > 0) { message = true; Timer.DelayCall(TimeSpan.FromMinutes(2), mobile => { if (Queue.ContainsKey(m)) { EncounterType type = Queue[m]; ShadowguardInstance instance = GetAvailableInstance(type); if (instance != null && instance.TryBeginEncounter(m, true, type)) { RemoveFromQueue(m); } } }, m); } break; } ColUtility.Free(copy); if (message && Queue.Count > 0) { ColUtility.For(Queue.Keys, (i, mob) => { Party p = Party.Get(mob); if (p != null) { for (var index = 0; index < p.Members.Count; index++) { var info = p.Members[index]; info.Mobile.SendLocalizedMessage(1156190, i + 1 > 1 ? i.ToString() : "next"); } } //A Shadowguard encounter has opened. You are currently ~1_NUM~ in the //queue. If you are next, you may proceed to the entry stone to join. else { mob.SendLocalizedMessage(1156190, i + 1 > 1 ? i.ToString() : "next"); } }); } }
public override void DoTurn(Grid p_grid, Party p_party) { m_owner.SkipMovement.Trigger(); }
public override TimedMethod[] Use() { Attacks.SetAudio("Blunt Hit", 6); if (Party.enemyCount == 1 || !Attacks.EvasionCheck(Party.GetEnemy(), Party.GetPlayer().GetAccuracy())) { return(new TimedMethod[] { new TimedMethod(0, "Audio", new object[] { "Small Swing" }), new TimedMethod(0, "StagnantAttack", new object[] { true, Party.GetPlayer().GetStrength(), Party.GetPlayer().GetStrength() + 5, Party.GetPlayer().GetAccuracy(), true, true, false }) }); } int[] pool = new int[Party.enemyCount - 1]; int index = 0; for (int i = 0; i < 4; i++) { if (i != Party.enemySlot - 1 && Party.enemies[i] != null && Party.enemies[i].GetAlive()) { pool[index] = i; index++; } } System.Random rng = new System.Random(); int former = Party.enemySlot; Party.enemySlot = pool[rng.Next(Party.enemyCount - 1)] + 1; return(new TimedMethod[] { new TimedMethod(0, "Audio", new object[] { "Small Swing" }), new TimedMethod(0, "AttackAny", new object[] { Party.GetPlayer(), Party.enemies[former - 1], Party.GetPlayer().GetStrength(), Party.GetPlayer().GetStrength() + 4, Party.GetPlayer().GetAccuracy(), true, true, false }), new TimedMethod(0, "EnemySwitch", new object[] { Party.enemySlot, former }), new TimedMethod(60, "Log", new object[] { Party.GetEnemy().ToString() + " was sent out" }) }); }
void OnEnable () { if (CurrentParty == null) { CurrentParty = new Party(PhotonNetwork.player); } nonGmPlayers = new PhotonPlayer[9]; GmPlayers = new PhotonPlayer[11]; ConnectedPlayers = PhotonNetwork.playerList; int counter = 0; int gmcounter = 0; foreach (GameObject _object in PlayerButtons) { _object.SetActive(false); } foreach (GameObject _object in PartyButtons) { _object.SetActive(false); } foreach (PhotonPlayer _player in ConnectedPlayers) { if (_player.name != "" && _player.name != PhotonNetwork.player.name) { nonGmPlayers[counter] = _player; PlayerButtons[counter].SetActive(true); PlayerButtons[counter].GetComponentInChildren<Text>().text = _player.name; counter++; } else if (_player.name != PhotonNetwork.player.name && !_player.isMasterClient) { GmPlayers[gmcounter] = _player; gmcounter++; } } updateCurrentPartyUi(); }