private async Task <RaidInfo> GetRaid(int raidId) { //Maybe it's in the most recent 10? RaidInfo[] raids = await client.GetRaids(10, 0); RaidInfo raid = raids?.FirstOrDefault(x => x.Id == raidId); if (raid != null && raid.Id == raidId) { return(raid); } else { log.LogWarning($"Could not find raid {raidId} in last 10 raids, searching whole list:"); // We could try to get fancy and binary search this thing. // However, requests have overhead, and we don't actually know how many raids there are (there could be gaps in IDs) // So until proven otherwise, getting the whole damn list of raids is probably just as quick. raids = await client.GetAllRaids(); raid = raids?.FirstOrDefault(x => x.Id == raidId); if (raid != null) { return(raid); } else { throw new RaidNotFoundException($"Could not find raid id '{raidId}'."); } } }
public async Task <RaidInfo> GetDailyItemsRaid() { DateTime today = DateTime.Today.Date; if (state.CurrentRaid == null || state.CurrentRaid.Date != today) { RaidInfo[] raids = await client.GetRaids(10, 0); RaidInfo raid = raids?.FirstOrDefault(x => x.Date.Date == today); if (raid != null) { return(raid); } raids = await client.GetAllRaids(); raid = raids?.FirstOrDefault(x => x.Date.Date == today); if (raid != null) { state.CurrentRaid = raid; } else { state.CurrentRaid = await StartRaid(config.DailyItemsEventId, new[] { config.BotCharacterId }, 0, $"Items for {today.ToShortDateString()}"); } } return(state.CurrentRaid); }
public void CompareToMultiples() { //Arrange RaidInfo raid = new RaidInfo(); Auction auction = new Auction(23423, 2, "Nuke", 2, raid, GetMessage(44)); RankConfiguration main = new RankConfiguration("main", null, 1); RankConfiguration box = new RankConfiguration("box", 100, 1); RankConfiguration alt = new RankConfiguration("alt", 25, 1); AuctionBid mainBid = new AuctionBid(auction, "main", 1, 104, main, GetAuthor(1)); AuctionBid boxBid1 = new AuctionBid(auction, "box1", 1, 300, box, GetAuthor(2)); AuctionBid BoxBid2 = new AuctionBid(auction, "box2", 1, 250, box, GetAuthor(3)); AuctionBid altBid = new AuctionBid(auction, "alt", 1, 54, alt, GetAuthor(4)); List <AuctionBid> list = new List <AuctionBid> { altBid, boxBid1, mainBid, BoxBid2 }; //Act list.Sort(); //Assert Assert.AreEqual(mainBid, list[0]); Assert.AreEqual(boxBid1, list[1]); Assert.AreEqual(BoxBid2, list[2]); Assert.AreEqual(altBid, list[3]); }
internal static Embed RaidEnded(STDTContext db, RaidInfo ri, IGuild guild) { List <RaidAttendee> Attendees = db.RaidAttendees.ToList().Where(x => x.RaidID == Globals._activeRaid.RaidID).ToList(); var emb = new EmbedBuilder() { Color = Globals.SuccessColor, Description = $"Raid {ri.RaidID} (started {ri.DateOfRaid}) Successfully Ended!\r\n" + $"Counted {Attendees.Count} attendees.\r\n" + GetAttendeesString(), Footer = new EmbedFooterBuilder().WithIconUrl(_config[$"guilds:{guild.Id}:logo"]).WithText(_config[$"guilds:{guild.Id}:name"]) }; string GetAttendeesString() { StringBuilder sb = new StringBuilder(); Attendees.ForEach(x => { User DBuser = db.Users.Find(x.UserID); sb.AppendLine($"{DBuser.Username} - {x.MinutesInRaid} minutes - {x.PointsObtained} points."); }); return(sb.ToString()); } return(emb.Build()); }
public void MergeFrom(GetRaidDetailsResponse other) { if (other == null) { return; } if (other.lobby_ != null) { if (lobby_ == null) { lobby_ = new global::POGOProtos.Data.Raid.Lobby(); } Lobby.MergeFrom(other.Lobby); } if (other.raidBattle_ != null) { if (raidBattle_ == null) { raidBattle_ = new global::POGOProtos.Data.Battle.Battle(); } RaidBattle.MergeFrom(other.RaidBattle); } if (other.PlayerCanJoinLobby != false) { PlayerCanJoinLobby = other.PlayerCanJoinLobby; } if (other.Result != 0) { Result = other.Result; } if (other.raidInfo_ != null) { if (raidInfo_ == null) { raidInfo_ = new global::POGOProtos.Data.Raid.RaidInfo(); } RaidInfo.MergeFrom(other.RaidInfo); } if (other.TicketUsed != false) { TicketUsed = other.TicketUsed; } if (other.FreeTicketAvailable != false) { FreeTicketAvailable = other.FreeTicketAvailable; } if (other.ThrowsRemaining != 0) { ThrowsRemaining = other.ThrowsRemaining; } if (other.ReceivedRewards != false) { ReceivedRewards = other.ReceivedRewards; } if (other.NumPlayersInLobby != 0) { NumPlayersInLobby = other.NumPlayersInLobby; } }
public async Task <RaidInfo> UseRaid(int raidId) { RaidInfo raid = await GetRaid(raidId); state.CurrentRaid = raid; return(raid); }
private static LootEntry GetLootEntry(string tableId, RaidInfo raid) { LootTable lootTable = LootDatabase.LootTables[tableId.ToUpper()]. Find(table => ((table.Difficulty == raid.Quest.Difficulty) || (table.Difficulty == 0)) && ((table.Dungeon == raid.Dungeon.Name) || (table.Dungeon == ""))); LootEntry lootEntry = RandomSolver.ChooseBySingleRandom(lootTable.Entries); return(lootEntry.Type != LootType.Table ? lootEntry : GetLootEntry(((LootEntryTable)lootEntry).TableId, raid)); }
public override int GetHashCode() { int hash = 1; if (lobby_ != null) { hash ^= Lobby.GetHashCode(); } if (raidBattle_ != null) { hash ^= RaidBattle.GetHashCode(); } if (PlayerCanJoinLobby != false) { hash ^= PlayerCanJoinLobby.GetHashCode(); } if (Result != 0) { hash ^= Result.GetHashCode(); } if (raidInfo_ != null) { hash ^= RaidInfo.GetHashCode(); } if (TicketUsed != false) { hash ^= TicketUsed.GetHashCode(); } if (FreeTicketAvailable != false) { hash ^= FreeTicketAvailable.GetHashCode(); } if (ThrowsRemaining != 0) { hash ^= ThrowsRemaining.GetHashCode(); } if (ReceivedRewards != false) { hash ^= ReceivedRewards.GetHashCode(); } if (NumPlayersInLobby != 0) { hash ^= NumPlayersInLobby.GetHashCode(); } if (ServerMs != 0L) { hash ^= ServerMs.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
internal static Embed RaidStarted(RaidInfo ri, IGuildUser user) { var emb = new EmbedBuilder() { Color = Globals.SuccessColor, Description = $"Raid {ri.RaidID} started by {user.Username}!", Footer = new EmbedFooterBuilder().WithIconUrl(_config[$"guilds:{user.GuildId}:logo"]).WithText(_config[$"guilds:{user.GuildId}:name"]) }; return(emb.Build()); }
public async Task StopRaid() { await _commands.RaidFinished().ConfigureAwait(false); RaidInfo ri = Globals._activeRaid; Globals._activeRaid = null; Globals.AlreadyRaided.Clear(); IGuild g = Context.Guild; await Context.Channel.SendMessageAsync("", false, Embeds.RaidEnded(_db, ri, g)).ConfigureAwait(false); }
public static List <ItemDefinition> GenerateLoot(string code, int amount, RaidInfo raid) { List <ItemDefinition> lootItems = new List <ItemDefinition>(); for (int j = 0; j < amount; j++) { LootEntry entry = GetLootEntry(code, raid); switch (entry.Type) { case LootType.Item: LootEntryItem itemEntry = entry as LootEntryItem; ItemDefinition data = new ItemDefinition(); data.Type = itemEntry.ItemType; data.Id = itemEntry.ItemId; data.Amount = itemEntry.ItemAmount; lootItems.Add(data); break; case LootType.Journal: LootEntryJournal journalEntry = entry as LootEntryJournal; ItemDefinition dataJournal = new ItemDefinition(); dataJournal.Type = "journal_page"; if (journalEntry.SpecificId.HasValue) { dataJournal.Id = journalEntry.SpecificId.Value.ToString(); } else { dataJournal.Id = RandomSolver.Next(journalEntry.MinIndex, journalEntry.MaxIndex + 1).ToString(); } dataJournal.Amount = 1; lootItems.Add(dataJournal); break; case LootType.Trinket: LootEntryTrinket trinketEntry = entry as LootEntryTrinket; var trinketList = DarkestDungeonManager.Data.Items["trinket"].Values.ToList(). FindAll(trinket => ((Trinket)trinket).RarityId == trinketEntry.Rarity); Trinket trinketItem = (Trinket)trinketList[RandomSolver.Next(trinketList.Count)]; ItemDefinition trinketDef = new ItemDefinition(); trinketDef.Type = trinketItem.Type; trinketDef.Id = trinketItem.Id; trinketDef.Amount = 1; lootItems.Add(trinketDef); break; case LootType.Nothing: break; } } return(lootItems); }
public ActionResult Create(RaidInfo model) { try { // TODO: Add insert logic here _db.Insert(model); return(RedirectToAction("Index")); } catch { return(View()); } }
public Auction(int id, int quantity, string name, double minutesRemaining, RaidInfo raid, IMessage message) { ID = id; Name = name; Quantity = quantity; MinutesRemaining = minutesRemaining; Author = message.Author; Channel = message.Channel; Raid = raid; timer = new Timer(TimeSpan.FromMinutes(0.5).TotalMilliseconds); timer.AutoReset = true; timer.Elapsed += OnTick; }
public ActionResult Edit(int id, RaidInfo model) { try { // TODO: Add update logic here int i = _db.Update(model); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, RaidInfo model) { try { // TODO: Add delete logic here _db.Delete <RaidInfo>("WHERE guid = @0", id); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task StartRaid() { RaidInfo newRaid = new RaidInfo(); newRaid.DateOfRaid = DateTime.UtcNow; _db.Raids.Add(newRaid); await _db.SaveChangesAsync(); Globals._activeRaid = newRaid; await _commands.CheckUsersInRaidChannel().ConfigureAwait(false); await Context.Channel.SendMessageAsync("", false, Embeds.RaidStarted(Globals._activeRaid, Context.User as IGuildUser)).ConfigureAwait(false); }
public int MakeEventsEachRaid(RaidInfo info, string start, string end) { DateTime startDate = DateTime.Parse(start); DateTime endDate = DateTime.Parse(end); List <ResetEvent> events = new List <ResetEvent>(); DateTime termDate = DateTime.Parse(info.start); while (startDate < endDate) { if (true == info.isThurReset) { if ((DayOfWeek.Thursday == startDate.DayOfWeek) && (startDate >= termDate)) { var newEvent = new ResetEvent(info.name, startDate, info.resourceId); events.Add(newEvent); startDate = startDate.AddDays(7f); } else { startDate = startDate.AddDays(1f); } } else { while (startDate > termDate) { termDate = termDate.AddDays(info.term); } if (startDate == termDate) { var newEvent = new ResetEvent(info.name, startDate, info.resourceId); events.Add(newEvent); startDate = startDate.AddDays(info.term); termDate = termDate.AddDays(info.term); } else { startDate = startDate.AddDays(1f); } } } int insertCount = ResetEventRepo.Get().Add(events); return(insertCount); }
public void BidsMustBePositive() { //Arrange RaidInfo raid = new RaidInfo(); Auction auction = new Auction(23423, 1, "Nuke", 2, raid, GetMessage(42)); RankConfiguration rank1 = new RankConfiguration("rank1", null, 1); //Act Action act = () => { new AuctionBid(auction, "foo", 42, 0, rank1, GetAuthor(1)); }; //Assert act.Should().Throw <InvalidBidException>(); }
public void Compare(int?bid1, int?cap1, int?bid2, int?cap2, ExpectedWinner expected) { //Arrange RaidInfo raid = new RaidInfo(); Auction auction = new Auction(23423, 1, "Nuke", 2, raid, GetMessage(42)); RankConfiguration rank1 = new RankConfiguration("rank1", cap1, 1); RankConfiguration rank2 = new RankConfiguration("rank2", cap2, 1); AuctionBid a1 = bid1 != null ? new AuctionBid(auction, "1", 1, bid1.Value, rank1, GetAuthor(45)) : null; AuctionBid a2 = bid2 != null ? new AuctionBid(auction, "2", 2, bid2.Value, rank2, GetAuthor(41)) : null; //Act int comparison = a1?.CompareTo(a2) ?? 0; ExpectedWinner actual = comparison < 0 ? ExpectedWinner.First : comparison > 0 ? ExpectedWinner.Second : ExpectedWinner.Tie; //Assert Assert.AreEqual(expected, actual); }
public async Task <Auction> StartAuction(int?quantity, string name, int?minutes, IMessage message) { RaidInfo raid = await dkpProcessor.GetDailyItemsRaid(); Auction auction = new Auction(state.NextAuctionId, quantity ?? 1, name, minutes ?? configuration.DefaultAuctionDurationMinutes, raid, message); if (!state.Auctions.TryAdd(auction.Name, auction)) { throw new AuctionAlreadyExistsException($"Auction for {auction.Name} already exists."); } try { ItemLookupResult itemResult = await itemProcessor.GetItemEmbed(name); string announcementText = auction.GetAnnouncementText(configuration.Ranks); if (itemResult?.MatchesFound > 1) { announcementText += "There were several items found with the same name, this might not actually be the correct item stats."; } IUserMessage announcement = await auction.Channel.SendMessageAsync(announcementText, false, itemResult?.Embed); auction.Tick += async(o, s) => await announcement.ModifyAsync(m => m.Content = auction.GetAnnouncementText(configuration.Ranks)); auction.Completed += async(o, s) => { await announcement.ModifyAsync(m => m.Content = auction.ClosedText); await FinishAuction(auction, announcement); }; auction.Start(); log.LogTrace("Started auction: {0}", auction.DetailDescription); return(auction); } catch (Exception) { state.Auctions.TryRemove(auction.Name, out Auction _); throw; } }
public void SetUp() { state = new AuctionState(); dkpProcessor = new Mock <IDkpProcessor>(); itemProcessor = new Mock <IItemProcessor>(); configuration = new DkpBotConfiguration { Ranks = new[] { alt, box, main } }; raid = new RaidInfo(); Mock <IMessageChannel> channel = new Mock <IMessageChannel>(); channel.Setup(x => x.SendMessageAsync(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <Embed>(), It.IsAny <RequestOptions>())) .Returns(Task.FromResult(new Mock <IUserMessage>().Object)); message = new Mock <IMessage>(); message.SetupGet(x => x.Channel).Returns(channel.Object); target = new AuctionProcessor(configuration, state, itemProcessor.Object, dkpProcessor.Object, new Mock <ILogger <AuctionProcessor> >().Object); }
void SelectShip(Ship s) { if (GameManager.instance.player.isRaiding && !GameManager.instance.player.IsShipInRaid(s.name)) { Ship playerShip = GameManager.instance.player.shipToRaidWith; int goldAmount = nameToGoldMapping[s.name]; float totalSuccessPercentage = CalculateTotalSuccessPercentage(playerShip, s); int duration = Map.GetDistanceBetweenPoints(playerShip.gridPos, s.gridPos); float capturePercentage = CalculateCapturePercentage(playerShip, s); RaidInfo raidInfo = new RaidInfo { goldAmount = goldAmount, duration = duration + 1, successRate = totalSuccessPercentage, captureChance = capturePercentage }; preRaidInfoPanel.Show(); preRaidInfoPanel.SetShipInfo(s); preRaidInfoPanel.SetRaidInfo(raidInfo); } }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (LastModifiedTimestampMs != 0L) { hash ^= LastModifiedTimestampMs.GetHashCode(); } if (Latitude != 0D) { hash ^= Latitude.GetHashCode(); } if (Longitude != 0D) { hash ^= Longitude.GetHashCode(); } if (OwnedByTeam != 0) { hash ^= OwnedByTeam.GetHashCode(); } if (GuardPokemonId != 0) { hash ^= GuardPokemonId.GetHashCode(); } if (GuardPokemonCp != 0) { hash ^= GuardPokemonCp.GetHashCode(); } if (Enabled != false) { hash ^= Enabled.GetHashCode(); } if (Type != 0) { hash ^= Type.GetHashCode(); } if (GymPoints != 0L) { hash ^= GymPoints.GetHashCode(); } if (IsInBattle != false) { hash ^= IsInBattle.GetHashCode(); } hash ^= activeFortModifier_.GetHashCode(); if (lureInfo_ != null) { hash ^= LureInfo.GetHashCode(); } if (CooldownCompleteTimestampMs != 0L) { hash ^= CooldownCompleteTimestampMs.GetHashCode(); } if (Sponsor != 0) { hash ^= Sponsor.GetHashCode(); } if (RenderingType != 0) { hash ^= RenderingType.GetHashCode(); } if (DeployLockoutEndMs != 0L) { hash ^= DeployLockoutEndMs.GetHashCode(); } if (guardPokemonDisplay_ != null) { hash ^= GuardPokemonDisplay.GetHashCode(); } if (Closed != false) { hash ^= Closed.GetHashCode(); } if (raidInfo_ != null) { hash ^= RaidInfo.GetHashCode(); } if (gymDisplay_ != null) { hash ^= GymDisplay.GetHashCode(); } if (Visited != false) { hash ^= Visited.GetHashCode(); } if (SameTeamDeployLockoutEndMs != 0L) { hash ^= SameTeamDeployLockoutEndMs.GetHashCode(); } if (AllowCheckin != false) { hash ^= AllowCheckin.GetHashCode(); } if (ImageUrl.Length != 0) { hash ^= ImageUrl.GetHashCode(); } if (InEvent != false) { hash ^= InEvent.GetHashCode(); } if (BannerUrl.Length != 0) { hash ^= BannerUrl.GetHashCode(); } return(hash); }
private List<RaidStageInfo> GetStages(RaidInfo raid) { Raids = MissionModelLocator.Instance.GetCurrentRaids(); for (int i = 0; i < Raids.Count; i++) { if (Raids[i].TemplateId == raid.TemplateId) { return Raids[i].StateInfo; } } return raid.StateInfo; }
public void AddNewStage(SCRaidNewStage stage) { var stageinfo = new RaidStageInfo(); stageinfo.Star = 0; stageinfo.TemplateId = stage.StageTemplateId; bool flag = true; var raids = GetCurrentRaids(); for (int i = 0; i < raids.Count; i++) { if (raids[i].TemplateId == stage.RaidTemplateId) { raids[i].StateInfo.Add(stageinfo); flag = false; } } if (flag) { MissionStep = RaidType.StepRaidList; var raid = new RaidInfo(); raid.TemplateId = stage.RaidTemplateId; raid.StateInfo = new List<RaidStageInfo>(); raid.StateInfo.Add(stageinfo); raids.Add(raid); } SetCurrentRaids(raids); }
private void SetStageList(RaidInfo raid) { MissionModelLocator.Instance.MissionStep = RaidType.StepStageList; MapContainer.SetActive(true); ItemsContainer.SetActive(true); FriendContainer.SetActive(false); RewardBox.SetActive(true); var boximage = RewardBox.transform.FindChild("Background").gameObject; var boxbg = boximage.GetComponent<UISprite>(); HasReward = false; if (raid.StateInfo.Count <= 1) { boxbg.color = new Color(0.33f, 0.33f, 0.33f, 1); } else if (raid.StateInfo[raid.StateInfo.Count - 1].Star <= 0) { boxbg.color = new Color(0.33f, 0.33f, 0.33f, 1); } else if (!MissionModelLocator.Instance.RaidLoadingAll.HasAwardInfo.Contains(raid.TemplateId)) { HasReward = MissionModelLocator.Instance.HasRaidReward(raid.TemplateId); if (HasReward) { boxbg.color = new Color(255, 255, 255, 1); } else { boxbg.color = new Color(0.33f, 0.33f, 0.33f, 1); } } else { RewardBox.SetActive(false); } var table = ItemsContainer.GetComponent<KxVListRender>(); var stages = GetStages(raid); List<RaidStageInfo> temp; if (MissionModelLocator.Instance.CurrRaidType == RaidType.RaidNormal) { temp = new List<RaidStageInfo>(stages.OrderByDescending(stageinfo => stageinfo.TemplateId)); } else { temp = new List<RaidStageInfo>(stages.OrderBy(stageinfo => stageinfo.TemplateId)); } table.Init(temp, "Prefabs/Component/MissionItem", 537, 521, 537, 160, OnItemClicktHandler); var lb = MapInfoLabel.GetComponent<UILabel>(); var raidtemp = MissionModelLocator.Instance.GetRaidByTemplateId(raid.TemplateId); lb.text = raidtemp.RaidName + "\n " + raidtemp.RaidDesc; var addition = MissionModelLocator.Instance.GetAdditionInfoByRaidTemplateID(raid.TemplateId); if (addition != null) { MapEvent.SetActive(true); var sp = EventSprite.GetComponent<UISprite>(); var lbname = EventNameLabel.GetComponent<UILabel>(); var lbtime = EventTimeLabel.GetComponent<UILabel>(); //½ð±Ò150%¡¢Îä»ê150%¡¢ÌåÁ¦ÏûºÄ50%¡¢µôÂä¸ÅÂÊ150% switch (addition.AddtionType) { case RaidType.RaidAddtionTypeDrop: sp.spriteName = "icon_box"; lbname.text = "x1.5"; break; case RaidType.RaidAddtionTypeEnergy: sp.spriteName = "icon_energy"; lbname.text = "x0.5"; break; case RaidType.RaidAddtionTypeGold: sp.spriteName = "icon_gold"; lbname.text = "x1.5"; break; case RaidType.RaidAddtionTypeSprit: sp.spriteName = "icon_wuhun"; lbname.text = "x1.5"; break; } lbtime.text = MissionModelLocator.Instance.DestTime; } }
public List <RaidInfo> GetRaidDeviceList_NVMe() { //scan NVME raid device const int MAX_SEARCH_SCSI_PORT = 16; List <RaidInfo> infoList = new List <RaidInfo>(); IntPtr intPtr_nvmeid = IntPtr.Zero; //Pointer of ID info buffer IntPtr intPtr_nvmesmart = IntPtr.Zero; //Pointer of SMART info buffer IntPtr intPtr_port = IntPtr.Zero; //Pointer of physical info buffer byte[] port = new byte[16]; int raid_type = -1; int raid_status = -1; GCHandle handle_port = GCHandle.Alloc(port, GCHandleType.Pinned); intPtr_port = handle_port.AddrOfPinnedObject(); for (int i = 0; i < MAX_SEARCH_SCSI_PORT; i++) { int scsiport = i; bool res = getNvmePhyPort(i, intPtr_port, ref raid_type, ref raid_status); //Get physical info buffer, raid type and raid status of each scsi port (0 ~ MAX_SEARCH_SCSI_PORT) Marshal.Copy(port, 0, intPtr_port, port.Length); if (res) { for (int k = 0; k < 16; k++) //Get ID/SMART buffer foreach physical entity under physical info { if (port[k] == 0) { continue; } intPtr_nvmeid = IntPtr.Zero; byte[] id = new byte[4096]; GCHandle id_addr = GCHandle.Alloc(id, GCHandleType.Pinned); intPtr_nvmeid = id_addr.AddrOfPinnedObject(); intPtr_nvmesmart = IntPtr.Zero; byte[] smart = new byte[512]; GCHandle smart_addr = GCHandle.Alloc(smart, GCHandleType.Pinned); intPtr_nvmesmart = smart_addr.AddrOfPinnedObject(); ulong disksize = 0; //Use scsi port number and physical entity contents to get ID/SMART buffer and NVMe RAID disk size bool isgetData = getNVMEIdSmart(scsiport, port[k], intPtr_nvmeid, intPtr_nvmesmart, ref disksize); if (isgetData) { Marshal.Copy(id, 0, intPtr_nvmeid, id.Length); ASCIIEncoding ascii = new ASCIIEncoding(); string modelName = "", serial_number = "", firmware_version = ""; for (int j = 24; j <= 63; j++) { modelName += ascii.GetString(id, j, 1); modelName = modelName.Replace("\0", ""); } for (int j = 4; j <= 23; j++) { if (!id[i].Equals(0)) { serial_number += ascii.GetString(id, j, 1); } else { break; } } ///Model for (int j = 64; j <= 71; j++) { firmware_version += ascii.GetString(id, j, 1); } Console.WriteLine(modelName.Trim()); Console.WriteLine(serial_number.Trim()); Console.WriteLine(firmware_version.Trim()); Marshal.Copy(smart, 0, intPtr_nvmesmart, smart.Length); RaidInfo info = new RaidInfo(); info.id = id; info.smart = smart; info.raidType = raid_type; info.raidStatus = raid_status; info.nvmeDiskSize = disksize; infoList.Add(info); } } } } return(infoList); }
public List <RaidInfo> GetRaidDeviceList_SATA() { List <RaidInfo> infoList = new List <RaidInfo>(); byte[] id_buf = new byte[512]; byte[] smart_buf = new byte[512]; //scan SATA raid device const int MAX_SEARCH_SCSI_PORT = 16; for (int index = 0; index < MAX_SEARCH_SCSI_PORT; index++) { CSMI_SAS_PHY_INFO csni_sas_phy_info = new CSMI_SAS_PHY_INFO(); bool res = getPhyPort(index, ref csni_sas_phy_info); // Get physical info of each scsi port (0 ~ MAX_SEARCH_SCSI_PORT) IntPtr intPtr_id = IntPtr.Zero; //Pointer of ID info buffer IntPtr intPtr_smart = IntPtr.Zero; //Pointer of SMART info buffer IntPtr intPtr_addr = IntPtr.Zero; //Pointer of SASAddress from physical entity for (int i = 0; i < csni_sas_phy_info.bNumberOfPhys; i++) //Get ID/SMART buffer foreach physical entity under physical info { byte[] id = new byte[512]; GCHandle handle_id = GCHandle.Alloc(id, GCHandleType.Pinned); intPtr_id = handle_id.AddrOfPinnedObject(); byte[] smart = new byte[512]; GCHandle handle_smart = GCHandle.Alloc(smart, GCHandleType.Pinned); intPtr_smart = handle_smart.AddrOfPinnedObject(); byte[] addr = Encoding.GetEncoding("UTF-8").GetBytes(csni_sas_phy_info.Phy[i].Attached.bSASAddress); GCHandle handle_addr = GCHandle.Alloc(addr, GCHandleType.Pinned); intPtr_addr = handle_addr.AddrOfPinnedObject(); //Use physical entity contents to get ID/SMART buffer res = getIdSmart(index, csni_sas_phy_info.Phy[i].Attached.bPhyIdentifier, csni_sas_phy_info.Phy[i].bPortIdentifier, intPtr_addr, intPtr_id, intPtr_smart); if (res) { Marshal.Copy(id, 0, intPtr_id, id.Length); Marshal.Copy(smart, 0, intPtr_smart, smart.Length); string Model_number = ""; Model_number = UtilityClass.getModelName(id, false); Model_number = Model_number.Replace("\0", "").Trim(); if (Model_number.Length > 0) { string ctlName = ""; for (int j = 400; j < 410; j = j + 2) //get controller { if (smart[j] != 0 || smart[j + 1] != 0) { ctlName = string.Concat(ctlName, Convert.ToString((char)smart[j]), Convert.ToString((char)smart[j + 1])); } } if (ctlName.IndexOf("\0", StringComparison.OrdinalIgnoreCase) != -1) { ctlName = ctlName.Replace("\0", ""); } RaidInfo info = new RaidInfo(); info.id = id; info.smart = smart; info.ctl = ctlName.Trim();; infoList.Add(info); } } } } return(infoList); }
public List<RaidInfo> GetRaidsByType(int thetype) { var raidtemplates = RaidTemplates.RaidTmpls; var newraids = new List<RaidInfo>(); var raids = (thetype == RaidType.RaidElite) ? RaidLoadingAll.RaidInfoElite : RaidLoadingAll.RaidInfoMaster; foreach (KeyValuePair<int, RaidTemplate> item in raidtemplates) { if (item.Value.RaidType == thetype)// && PlayerModelLocator.Instance.Level >= item.Value.OpenLvl) { RaidInfo raid = null; for (int i = 0; i < raids.Count; i++) { if (raids[i].TemplateId == item.Value.Id) { raid = raids[i]; break; } } if (raid == null) { raid = new RaidInfo(); raid.TemplateId = item.Value.Id; raid.StateInfo = new List<RaidStageInfo>(); } foreach (KeyValuePair<int, RaidStageTemplate> stageitem in RaidTemplates.RaidStageTmpls) { if (stageitem.Value.RaidId == raid.TemplateId) { var flag = true; for (int i = 0; i < raid.StateInfo.Count; i++) { if (raid.StateInfo[i].TemplateId == stageitem.Value.Id) { flag = false; break; } } if (flag) { var stage = new RaidStageInfo(); stage.Star = 0; stage.TemplateId = stageitem.Value.Id; raid.StateInfo.Add(stage); } } } newraids.Add(raid); } } return newraids; }
public void LoadCurioLoot(Curio curio, CurioInteraction interaction, CurioResult curioResult, RaidInfo raid, bool keepLoot) { KeepLoot = keepLoot; if (keepLoot) { takeAllButton.gameObject.SetActive(false); passButton.gameObject.SetActive(false); partyInventory.SetDeactivated(); } else { takeAllButton.gameObject.SetActive(true); passButton.gameObject.SetActive(true); partyInventory.SetActivated(); } LootType = LootEventType.Curio; ActionType = LootResultType.Waiting; gameObject.SetActive(true); partyInventory.DiscardAll(); if (curio.IsQuestCurio) { if (curioResult != null) { partyInventory.DistributeItem(new ItemDefinition("quest_item", curioResult.Item, 1)); } } else { if (curioResult.IsCombined) { foreach (var result in interaction.Results) { if (result.IsCombined && result.Item != "Nothing") { foreach (var item in RaidSolver.GenerateLoot(result, raid)) { partyInventory.DistributeItem(item); } } } } else if (curioResult.Item != "Nothing") { foreach (var item in RaidSolver.GenerateLoot(curioResult, raid)) { partyInventory.DistributeItem(item); } } if (RaidSceneManager.RaidPanel.SelectedHero != null) { var extraLoot = RaidSceneManager.RaidPanel.SelectedHero.HeroClass.ExtraCurioLoot; if (extraLoot != null) { foreach (var item in RaidSolver.GenerateLoot(extraLoot.Code, extraLoot.Count, raid)) { partyInventory.DistributeItem(item); } } } } partyInventory.DeactivateEmptySlots(); title.text = LocalizationManager.GetString("str_overlay_loot_chest_title"); description.text = LocalizationManager.GetString("str_overlay_loot_chest_description"); if (partyInventory.HasSomething()) { ScrollOpened(); } else { Close(); } }
public void MergeFrom(FortData other) { if (other == null) { return; } if (other.Id.Length != 0) { Id = other.Id; } if (other.LastModifiedTimestampMs != 0L) { LastModifiedTimestampMs = other.LastModifiedTimestampMs; } if (other.Latitude != 0D) { Latitude = other.Latitude; } if (other.Longitude != 0D) { Longitude = other.Longitude; } if (other.OwnedByTeam != 0) { OwnedByTeam = other.OwnedByTeam; } if (other.GuardPokemonId != 0) { GuardPokemonId = other.GuardPokemonId; } if (other.GuardPokemonCp != 0) { GuardPokemonCp = other.GuardPokemonCp; } if (other.Enabled != false) { Enabled = other.Enabled; } if (other.Type != 0) { Type = other.Type; } if (other.GymPoints != 0L) { GymPoints = other.GymPoints; } if (other.IsInBattle != false) { IsInBattle = other.IsInBattle; } activeFortModifier_.Add(other.activeFortModifier_); if (other.lureInfo_ != null) { if (lureInfo_ == null) { lureInfo_ = new global::POGOProtos.Map.Fort.FortLureInfo(); } LureInfo.MergeFrom(other.LureInfo); } if (other.CooldownCompleteTimestampMs != 0L) { CooldownCompleteTimestampMs = other.CooldownCompleteTimestampMs; } if (other.Sponsor != 0) { Sponsor = other.Sponsor; } if (other.RenderingType != 0) { RenderingType = other.RenderingType; } if (other.DeployLockoutEndMs != 0L) { DeployLockoutEndMs = other.DeployLockoutEndMs; } if (other.guardPokemonDisplay_ != null) { if (guardPokemonDisplay_ == null) { guardPokemonDisplay_ = new global::POGOProtos.Data.PokemonDisplay(); } GuardPokemonDisplay.MergeFrom(other.GuardPokemonDisplay); } if (other.Closed != false) { Closed = other.Closed; } if (other.raidInfo_ != null) { if (raidInfo_ == null) { raidInfo_ = new global::POGOProtos.Data.Raid.RaidInfo(); } RaidInfo.MergeFrom(other.RaidInfo); } if (other.gymDisplay_ != null) { if (gymDisplay_ == null) { gymDisplay_ = new global::POGOProtos.Map.Fort.GymDisplay(); } GymDisplay.MergeFrom(other.GymDisplay); } if (other.Visited != false) { Visited = other.Visited; } if (other.SameTeamDeployLockoutEndMs != 0L) { SameTeamDeployLockoutEndMs = other.SameTeamDeployLockoutEndMs; } if (other.AllowCheckin != false) { AllowCheckin = other.AllowCheckin; } if (other.ImageUrl.Length != 0) { ImageUrl = other.ImageUrl; } if (other.InEvent != false) { InEvent = other.InEvent; } if (other.BannerUrl.Length != 0) { BannerUrl = other.BannerUrl; } }
public static Auction NewAuction(this RaidInfo raid, int quantity) { Auction auction = new Auction(23423, quantity, "Nuke", 2, raid, GetMessage(42)); return(auction); }
/// <summary> /// Read this whole class from string. /// </summary> /// <param name="value"></param> public void ReadClass(string value) { string[] splitStrings = new string[] { BasicName, RaidClassName, FriendDataClassName, TotalStarDictionaryName }; string[] outStrings = value.Split(splitStrings, StringSplitOptions.RemoveEmptyEntries); PersistenceFileIOHandler.CheckCount(outStrings, FieldCount - 1, FieldCount); string[] splitedBasic = outStrings[0].Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); PersistenceFileIOHandler.CheckCount(splitedBasic,BasicFieldCount); if (BattleStageTemplate == null)BattleStageTemplate = new RaidStageTemplate(); BattleStageTemplate.Id = int.Parse(splitedBasic[0]); OldExp = int.Parse(splitedBasic[1]); OldLevel = int.Parse(splitedBasic[2]); StarCount = int.Parse(splitedBasic[3]); Raid = new RaidInfo(); Raid.ReadClass(outStrings[1]); FriendData=new FriendVO(); FriendData.ReadClass(outStrings[2]); if (outStrings.Length == FieldCount) { string[] splitedTotalStarDic = outStrings[3].Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (splitedTotalStarDic.Length % 2 != 0) { Logger.LogError("Not correct string num!"); throw new Exception("ReadTotalStarDic: Not couple strings num"); } TotalStarCount = PersistenceFileIOHandler.ReadDic<int, int>(splitedTotalStarDic, 0, splitedTotalStarDic.Length - 1); } else { Logger.LogWarning("A TotalStarCountDic is empty."); } }