private void SyncCompleteBounty() { activeBounty.Complete(); activeBounty = null; Destroy(activeBountySpawn.childCount > 0 ? activeBountySpawn.GetChild(0).gameObject : null); ToggleView(); }
//Below function, fills out all the variables on the bountyDisplay taking the information from the Bounty(Scriptable Object). //Also fills out where the bountyTarget will spawn. void currentBounty() { bounty = bountyList [currentBountyListNum]; bountyNameText.text = bounty.bountyName; bountyDescription.text = bounty.bountyDescription; bountyImage.sprite = bounty.bountyImage; bountyRewardText.text = "$" + bounty.bountyRewardAmount.ToString(); rewardFromBounty = bounty.bountyRewardAmount; spawnLocation = bounty.spawnBountyLocation; targetBounty = bounty.bountyTarget; //Below the object is spawning a prefab, naming it to current bounty name, and set the object false. newBounty = Instantiate(targetBounty, spawnLocation, Quaternion.identity); newBounty.name = bounty.bountyName; newBounty.SetActive(false); // bountyNameText.text = bounty.bountyName; // bountyDescription.text = bounty.bountyDescription; // // bountyImage.sprite = bounty.bountyImage; // // bountyRewardText.text = bounty.bountyRewardAmount.ToString (); }
private void endGame(SocketIOEvent obj) { Bounty bounty = new Bounty(); bounty.fillWithRawData(obj.data); onGameFinished(bounty); }
public async Task <IActionResult> PutBounty(int id, Bounty bounty) { // TODO: Change this if (id != bounty.BountyId) { return(BadRequest()); } DbContext.Entry(bounty).State = EntityState.Modified; try { await DbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BountyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void showBounty(Bounty b) { buildingNameText.text = b.building.GetComponent <Building>().buildingName; bountyCredit.text = "You will gain " + b.credit + " credits"; bountyTime.text = "You have\n<b>" + b.time.ToString("F1") + " seconds</b>\nto complete this bounty"; StartCoroutine(bountyShowing()); }
public IActionResult Create([FromBody] Bounty bounty) { // Check that serialization was successful if (bounty == null) { return(BadRequest()); } // Check if the client passed an Id if (bounty.Id > 0) { ModelState.AddModelError("Id", "Model Ids are automatically generated. Do not pass an Id on creation."); } // Validate inputs if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // Add bounty _context.Bounties.Add(bounty); _context.SaveChanges(); return(CreatedAtRoute("GetBounty", new { id = bounty.Id }, bounty)); }
internal BountyEvent InvokeEvent(BountyEvent arg) { if (_api.ValidateEvent(arg)) { Bounty?.Invoke(_api, arg); } return(arg); }
private void enemyDCAccepted(SocketIOEvent obj) { Console.WriteLine("Enemy is DC"); Bounty bounty = new Bounty(); bounty.fillWithRawData(obj.data); onEnemyDCAccepted(bounty); }
public void TestConstruction() { var auction = new Bounty(SmartContractState, "Test Bounty SmartContract", "Test the bouny smartcontract and tools"); Assert.AreEqual(ContractOwnerAddress, SmartContractState.PersistentState.GetAddress("Owner")); Assert.AreEqual(0, SmartContractState.PersistentState.GetInt32("State")); Assert.AreEqual(1, SmartContractState.PersistentState.GetStructList <Bounty.BountyDeposit>("DeposittedBounties").Count); }
public void AddBounty(Bounty bounty) { BountyRef bountyRef = bountyList.Add(bounty); if (bountyRef != null) { startBountyEvent.Invoke(bountyRef); } }
public static void ClearBounty(Bounty contract, Mobile wanted) { if (contract == null || wanted == null) { return; } BountyTable.Remove(contract); BountyTable.Remove(wanted); }
public BountyDTO(Bounty bounty, bool includeQuestion) { BountyId = bounty.BountyId; Amount = bounty.Amount; AmountSym = bounty.AmountSym; Question = includeQuestion ? new QuestionDTO(bounty.Question, null) : null; Owner = bounty.Owner; Awarded = bounty.Awarded; IsCreatedOnBlockchain = bounty.IsCreatedOnBlockchain; }
public static Bounty FindBounty(Mobile m) { if (m == null) { return(null); } Bounty b = (Bounty)BountyTable[m]; return(b); }
public static void SetExpires(Mobile wanted, DateTime expires) { if (wanted != null) { Bounty b = FindBounty(wanted); if (b != null) { b.SetExpires(expires); } } }
public static void AddReward(Mobile wanted, int amount) { if (wanted != null && amount > 0) { Bounty b = FindBounty(wanted); if (b != null) { b.AddReward(amount); } } }
public BountyRef Add(Bounty bounty) { Debug.Assert(bounty != null, "Attempting to add null bounty to BountyList"); BountyRef foundBounty = bountyList.Find((b) => b.ReferencedBounty == bounty); if (foundBounty == null) { BountyRef bountyRef = new BountyRef(bounty); bountyList.Add(bountyRef); return(bountyRef); } return(null); }
public void setBounty(Bounty b) { if (b.time != -1f) { buildingNameText.text = b.building.GetComponent <Building>().buildingName; bountyCredit.text = "You will gain " + b.credit + " credits"; bountyTime.text = "You have\n<b>" + b.time.ToString("F1") + " seconds</b>\nto complete this bounty"; } else { buildingNameText.text = "None now"; bountyCredit.text = ""; bountyTime.text = "You will be given bounties periodically"; } }
public static void Gather() { ArrayList list = new ArrayList(); foreach (Mobile m in World.Mobiles.Values) { Bounty b = FindBounty(m); if (b != null) { list.Add(b); } } GlobalBounties = list; }
public async Task <List <Embed> > AddAsync(string Player, string Description, string Reward, DateTime Expiration, string Type) { try { DateTime tmpExp = DateTime.Today.AddDays(7); if (Expiration != null) { tmpExp = Expiration; } KillsType tmpType; if (Type == "Clan") { tmpType = KillsType.Clan; } else { tmpType = KillsType.Personal; } Bounty bounty = new Bounty { BountyID = System.Guid.NewGuid(), PlayerName = Player, Description = Description, Reward = Reward, Log = new Dictionary <string, int>(), Type = tmpType, Expiration = tmpExp }; BountyList.Add(Player, bounty); bool saveresult = await SaveFileAsync(); List <Embed> result = await GetEmbedAsync(); return(result); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }
private void waitForPlayerToConnect(OnEnemyDCAccepted onEnemyDcAccepted, OnPlayerIsDC onPlayerIsDc) { bool responceRecieved = false; io.On(Constants.serverMessage.events.ENEMY_DC_ACCEPTED, (obj) => { responceRecieved = true; Bounty bounty = new Bounty(); bounty.fillWithRawData(obj.data); onEnemyDcAccepted(bounty); } ); Thread.Sleep(2000); if (responceRecieved == false) { onPlayerIsDc(); } }
public async Task <Bounty> IncrementKillAsync(Bounty bounty, string Player) { try { // currentCount will be zero if the key id doesn't exist.. bounty.Log.TryGetValue(Player, out int currentCount); bounty.Log[Player] = currentCount + 1; await SaveFileAsync(); return(bounty); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }
public static void UpdateBounty(Mobile wanted, int reward) { if (wanted == null || reward < 1) { return; } Bounty b = FindBounty(wanted); DateTime expires = DateTime.Now + TimeSpan.FromDays(30.0); if (b != null) { AddReward(wanted, reward); SetExpires(wanted, expires); wanted.SendMessage("A bounty has been placed on your head."); } }
private void SaveBounty(XmlTextWriter xml) { xml.WriteStartElement("bounty"); xml.WriteStartElement("serial"); xml.WriteString(BountyPlayer.Serial.Value.ToString()); xml.WriteEndElement(); xml.WriteStartElement("bountyAmount"); xml.WriteString(Bounty.ToString()); xml.WriteEndElement(); xml.WriteStartElement("lastBountyTime"); xml.WriteString(XmlConvert.ToString(LastBounty, XmlDateTimeSerializationMode.Utc)); xml.WriteEndElement(); xml.WriteEndElement(); }
public void TestCompleteFlow() { ((TestMessage)SmartContractState.Message).Value = 100; var bounty = new Bounty(SmartContractState, "Test Bounty SmartContract", "Test the bouny smartcontract and tools"); Assert.AreEqual(ContractOwnerAddress, SmartContractState.PersistentState.GetAddress("Owner")); Assert.AreEqual((int)Bounty.BountyState.New, SmartContractState.PersistentState.GetInt32("State")); Assert.AreEqual(1U, SmartContractState.PersistentState.GetStructList <Bounty.BountyDeposit>("DeposittedBounties").Count); // Add an extra deposit to the bounty. So the total bounty amount will become 150 STRAT SetSender(SecondDepositerAddress, 50); bounty.DepositBounty("Ocrasoft"); Assert.AreEqual(150u, bounty.TotalBounty); Assert.AreEqual(2u, SmartContractState.PersistentState.GetStructList <Bounty.BountyDeposit>("DeposittedBounties").Count); // Enroll the first developer SetSender(Developer1Address, 0); bounty.Enroll("Jeroen Veurink", "I like to make some money :)"); Assert.AreEqual((int)Bounty.BountyState.HasEnrollments, SmartContractState.PersistentState.GetInt32("State")); Assert.AreEqual(1u, SmartContractState.PersistentState.GetStructList <Bounty.Enrollment>("Enrollments").Count); // Enroll the second developer SetSender(Developer2Address, 0); bounty.Enroll("Wacky Hacker", "Give Me m0n3ys!"); Assert.AreEqual(2u, SmartContractState.PersistentState.GetStructList <Bounty.Enrollment>("Enrollments").Count); // Pick the first enrollment as winner var firstEnrollmentAddress = SmartContractState.PersistentState.GetStructList <Bounty.Enrollment>("Enrollments")[0].Address; SetSender(ContractOwnerAddress, 0); bounty.PickEnrollment(firstEnrollmentAddress); Assert.AreEqual((int)Bounty.BountyState.IsAssigned, SmartContractState.PersistentState.GetInt32("State")); SetSender(Developer1Address, 0); bounty.RequestReview(); Assert.AreEqual((int)Bounty.BountyState.UnderReview, SmartContractState.PersistentState.GetInt32("State")); SetSender(ContractOwnerAddress, 0); bounty.AcceptAndPayout(); Assert.AreEqual((int)Bounty.BountyState.Finished, SmartContractState.PersistentState.GetInt32("State")); }
public static void Load() { string idxPath = Path.Combine("Saves/FS Systems/FSBounty", "BountyTable.idx"); string binPath = Path.Combine("Saves/FS Systems/FSBounty", "BountyTable.bin"); if (File.Exists(idxPath) && File.Exists(binPath)) { FileStream idx = new FileStream(idxPath, FileMode.Open, FileAccess.Read, FileShare.Read); FileStream bin = new FileStream(binPath, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader idxReader = new BinaryReader(idx); BinaryFileReader binReader = new BinaryFileReader(new BinaryReader(bin)); int orderCount = idxReader.ReadInt32(); for (int i = 0; i < orderCount; ++i) { Bounty ps = new Bounty(); long startPos = idxReader.ReadInt64(); int length = idxReader.ReadInt32(); binReader.Seek(startPos, SeekOrigin.Begin); try { ps.Deserialize(binReader); if (binReader.Position != (startPos + length)) { throw new Exception(String.Format("***** Bad serialize on Bounty[{0}] *****", i)); } } catch { } if (ps != null && ps.Wanted != null) { BountyTable.Add(ps.Wanted, ps); } } idxReader.Close(); binReader.Close(); } }
public IActionResult Update(long id, [FromBody] Bounty bounty) { // Check that serialization was successful if (bounty == null) { return(BadRequest()); } // Check that the id parameter matches the model's id if (bounty.Id != id) { ModelState.AddModelError("Id", "The Id passed does not match the Id of the bounty data."); } // Validate inputs if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // Retrieve the entity to update var b = _context.Bounties.FirstOrDefault(x => x.Id == id); if (b == null) { return(NotFound()); } // Update data b.Name = bounty.Name; b.Description = bounty.Description; b.AliveReward = bounty.AliveReward; b.DeadReward = bounty.DeadReward; b.Captured = bounty.Captured; // Persist _context.Bounties.Update(b); _context.SaveChanges(); return(new NoContentResult()); }
/// <summary> /// Posts a bounty from one player to another /// </summary> /// <param name="postingPlayerName">Name of the player posting the bounty</param> /// <param name="targetPlayerName">Player who will have the bounty posted against them.</param> /// <param name="bountyValue">Value of the bounty on the target</param> /// <returns>BountyPostResult, detailing success of the operation, or if it failed, why.</returns> public static OperationResult PostBounty(string postingPlayerName, string targetPlayerName, int bountyValue) { var result = new OperationResult(); var postingPlayer = GetByName(postingPlayerName); if (postingPlayer == null) { result.Message = $"Posting player ${postingPlayerName} does not exist."; return(result); } var targetPlayer = GetByName(targetPlayerName); if (targetPlayer == null) { result.Message = $"Target player ${targetPlayerName} does not exist."; return(result); } if (postingPlayer.NetWorth.Value < bountyValue) { result.Message = $"You don't have enough Net Worth to back the bounty on ${targetPlayerName}. Use !NETWORTH ME to see your accumulated value."; return(result); } postingPlayer.NetWorth.Value -= bountyValue; Update(postingPlayer); var bounty = new Bounty { TargetPlayerId = targetPlayer.Id, PostedDate = DateTime.Now, Value = bountyValue }; BountyRepository.Create(bounty); return(result); }
public static void CreateBounty(Mobile wanted, int reward) { if (wanted == null || reward < 1) { return; } Bounty b = FindBounty(wanted); if (b != null) { UpdateBounty(wanted, reward); } else { DateTime expires = DateTime.Now + TimeSpan.FromDays(30.0); b = new Bounty(wanted, reward, expires); BountyTable.Add(wanted, b); wanted.SendMessage("A bounty has been placed on your head."); } }
void Update() { bountyIndicator.SetActive(isInBounty); if (isInBounty) { if (bountyStartTime + currentBounty.time <= Time.time) { Debug.Log("Bounty Failed"); isInBounty = false; Bounty nullB = new Bounty(); nullB.time = -1f; pauseMenuController.setBounty(nullB); StartCoroutine(waitToGiveNewBounty()); } if (currentBounty.building.GetComponent <Building>().isDestroyed) { Economy.playerCredits = currentBounty.credit; Debug.Log("Giving " + currentBounty.credit); isInBounty = false; StartCoroutine(waitToGiveNewBounty()); } } }
private void SyncActiveBounty(string bountyName, int progress) { if (activeBounty != null) { return; } for (int i = 0; i < availableBounties.Count; i++) { availableBounties[i].Reset(); if (availableBounties[i].bountyName == bountyName) { activeBounty = availableBounties[i]; activeBounty.bountyState = Bounty.BountyState.Active; activeBounty.progress = progress; BountyUI newBountyUI = Instantiate(bountyUIPrefab, activeBountySpawn.position, Quaternion.identity, activeBountySpawn).GetComponent <BountyUI>(); newBountyUI.Setup(activeBounty); } } ToggleView(); }
public static void ClearBounty( Bounty contract, Mobile wanted ) { if ( contract == null || wanted == null ) return; BountyTable.Remove( contract ); BountyTable.Remove( wanted ); }
public static void CreateBounty( Mobile wanted, int reward ) { if ( wanted == null || reward < 1 ) return; Bounty b = FindBounty( wanted ); if ( b != null ) { UpdateBounty( wanted, reward ); } else { DateTime expires = DateTime.Now + TimeSpan.FromDays( 30.0 ); b = new Bounty( wanted, reward, expires ); BountyTable.Add( wanted, b ); wanted.SendMessage( "A bounty has been placed on your head." ); } }
public static void Load() { string idxPath = Path.Combine( "Saves/FS Systems/FSBounty", "BountyTable.idx" ); string binPath = Path.Combine( "Saves/FS Systems/FSBounty", "BountyTable.bin" ); if ( File.Exists( idxPath ) && File.Exists( binPath ) ) { FileStream idx = new FileStream( idxPath, FileMode.Open, FileAccess.Read, FileShare.Read ); FileStream bin = new FileStream( binPath, FileMode.Open, FileAccess.Read, FileShare.Read) ; BinaryReader idxReader = new BinaryReader( idx ); BinaryFileReader binReader = new BinaryFileReader( new BinaryReader( bin ) ); int orderCount = idxReader.ReadInt32(); for ( int i = 0; i < orderCount; ++i ) { Bounty ps = new Bounty(); long startPos = idxReader.ReadInt64(); int length = idxReader.ReadInt32(); binReader.Seek( startPos, SeekOrigin.Begin ); try { ps.Deserialize(binReader); if (binReader.Position != ( startPos + length ) ) throw new Exception( String.Format( "***** Bad serialize on Bounty[{0}] *****", i ) ); } catch { } if ( ps != null && ps.Wanted != null ) BountyTable.Add( ps.Wanted, ps ); } idxReader.Close(); binReader.Close(); } }