protected void AddChips(Transform parent, long chips) { for (int i = parent.childCount - 1; i >= 0; i--) { GameObject.DestroyImmediate(parent.GetChild(i).gameObject); } BetData bd = BlackJack_Data.GetInstance().m_BetData[m_BjGameBase.m_RoomInfo.m_nRoomLevel - 1]; int[] grades = bd.m_nGrades; for (int i = grades.Length - 1; i >= 0; i--) { if (chips >= grades[i] || i == 0) { int index = i + (chips > grades[i] ? 2 : 1); UnityEngine.Object obj = (GameObject)m_BjGameBase.m_AssetBundle.LoadAsset("Model_chouma" + index); GameObject gameObj = GameMain.instantiate(obj) as GameObject; gameObj.transform.SetParent(parent, false); gameObj.GetComponentInChildren <TextMesh>().text = GameFunction.FormatCoinText(chips); break; } } CustomAudioDataManager.GetInstance().PlayAudio(1003); }
public void SendBetData(int betAmount, int totalBetInRound, string userAction, int roundNo) { BetData requestData = new BetData(); requestData.userData = new UserBetData(); requestData.userAction = userAction; requestData.userData.betData = totalBetInRound; requestData.userData.playerAction = userAction; requestData.userData.roundNo = roundNo; requestData.userId = "" + PlayerManager.instance.GetPlayerGameData().userId; requestData.tableId = TABLE_ID; requestData.bet = "" + betAmount; string requestStringData = JsonMapper.ToJson(requestData); object requestObjectData = Json.Decode(requestStringData); SocketRequest request = new SocketRequest(); request.emitEvent = "submitBet"; request.plainDataToBeSend = null; request.jsonDataToBeSend = requestObjectData; request.requestDataStructure = requestStringData; socketRequest.Add(request); }
private Task <string> MakeBet(int id, int?number, string color, int betMoney, string username) { var result = "Error: "; var roulette = GetRoulette(id); if (roulette == null || !roulette.open) { result += "Roulette is closed or it doesn't exist"; } else if ((number == null && color != null) || (number != null && color == null)) { if (((number != null && number >= 0 && number <= 36) || color != null) && (betMoney > 0 && betMoney <= 10000)) { var itm = new BetData() { Number = number ?? -1, Color = color, Bet = betMoney, Username = username }; roulette.bets.Add(itm); SaveRoulette(roulette); result = "Ok"; } else { result += "Check values [number from 0 to 36 or color: Red or Black]"; } } else { result += "Cannot make bet to number and color, choose one"; } return(Task <string> .FromResult(result)); }
public JsonResult Matches(BetData betData) { bool success; string UserMessage = ""; string DevMessage = ""; try { Bet bet = new Bet { Amount = betData.Amount, Odds = (decimal.Parse(betData.Odds)), Type = client.GetMatch(betData.MatchId), WinCondition = client.GetTeam(betData.TeamId) }; client.AddBetToUser(client.GetUser(betData.UserId), bet); success = true; UserMessage = "Bet was placed successfully"; } catch (Exception ex) { UserMessage = "Bet not placed, try again"; DevMessage = ex.StackTrace; success = false; } return(Json(new { success, UserMessage, DevMessage })); }
public void SaveBetObjectJSON(BetData betObj) { var jsonData = System.IO.File.ReadAllText("Assets/Resources/bookiesData.json"); DataSet dataSet = JsonConvert.DeserializeObject <DataSet>(jsonData.ToString()); DataTable dataTable = dataSet.Tables["bets"]; DataRow row = dataTable.NewRow(); row["betID"] = betObj.betID; row["dateMade"] = betObj.dateMade; row["fightDescription"] = betObj.fightDescription; row["fighterToWin"] = betObj.fighterToWin; row["betAmount"] = betObj.betAmount; row["punterName"] = betObj.punterName; row["fighterWon"] = betObj.fightWinner; dataTable.Rows.Add(row); string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented); //Debug.Log(json.ToString()); File.WriteAllText("Assets/Resources/bookiesData.json", json); }
public ActionResult SupportFriendPlaceBet() { int amount = 0; Int32.TryParse(Request["hfAmount"], out amount); string name = Request["tbName"]; string email = Request["tbEmail"]; //DO THE MAGIC HERE IUserDataRepository _repositoryU = new UserDataRepository(); UserData user = new UserData(); user = _repositoryU.FindByUsername(email); if (user == null) { user = new UserData(); user.FullName = name; if (String.IsNullOrEmpty(name) || name == null) { user.FullName = email; } user.Email = email; user = _repositoryU.Insert(user); } IBetDataRepository _repositoryB = new BetDataRepository(); BetData bet = new BetData(); bet.Username = User.Identity.Name; bet.User2ID = user.UserID; bet.BetActionID = 114; bet.BetValue = amount; bet = _repositoryB.Insert(bet); //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, WebSecurity.GetUserId(User.Identity.Name), 114).Add(); string hostName = System.Configuration.ConfigurationManager.AppSettings["HostName"]; string inviteUrl = hostName + "Home/Invited/" + bet.Guid + "/" + bet.BetActionID; string mailBody = "Hi " + name + ",<br><br>"; mailBody += User.Identity.Name + " is so certain of your driving skills he is prepared to bet €" + amount.ToString() + " on that.<br><br>"; mailBody += "Join SupportFriend, the social insurance provider and get up to 80% discount on your car insurance, now! <br><br>"; mailBody += inviteUrl; //Code.BasicMailing.SendEmail(email, "", User.Identity.Name + " wants to support you on SupportFriend", mailBody); return(Content("<li>" + email + "</li>")); /*return RedirectToAction("Index", "Dashboard");*/ //return View("Support-Me"); }
public JsonResult FacebookMessage(string amount, string betActionID, HttpPostedFileBase uplFile) { int amountInt = 0; Int32.TryParse(amount, out amountInt); IBetDataRepository _repositoryB = new BetDataRepository(); BetData bet = new BetData(); bet.Username = User.Identity.Name; bet.User2ID = 0; bet.BetActionID = Convert.ToInt16(betActionID); bet.BetValue = amountInt; string extension = String.Empty; if (uplFile != null && uplFile.ContentLength > 0) { extension = uplFile.FileName.Substring(uplFile.FileName.IndexOf(".") + 1, uplFile.FileName.Length - uplFile.FileName.IndexOf(".") - 1).ToLower(); bet.FileExtension = extension; } bet = _repositoryB.Insert(bet); if (uplFile != null && uplFile.ContentLength > 0) { int tmpuserID = WebSecurity.GetUserId(User.Identity.Name); var fileName = bet.Guid.ToString() + "_" + tmpuserID + "." + extension;//Path.GetFileName(uplFile.FileName); var path = Path.Combine(Server.MapPath("~/upload/policies/"), fileName); uplFile.SaveAs(path); IFileDataRepository repositoryF = new FileDataRepository(); FileData file = new FileData(); file.BetGuid = bet.Guid; file.FileTypeID = 207; //POLICY file.FileExtension = extension; file.FilePath = path; file.InsertUserID = tmpuserID; repositoryF.Insert(file); } //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, WebSecurity.GetUserId(User.Identity.Name), Convert.ToInt16(betActionID)).Add(); string hostName = System.Configuration.ConfigurationManager.AppSettings["HostName"]; return(Json(new { success = true, host = hostName, guid = bet.Guid, action = betActionID }, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult ProcessPurchase(PurchaseRequest purchase) { BetData betData = BetData.Parse(purchase.BetData); CustomerKey customerKey = _customerProvider.GetCurrentCustomer().Key; PurchaseErrorCode errorCode = ValidatePurchaseRequest(customerKey, betData.EstimatedTotalPrice); if (errorCode != PurchaseErrorCode.NotSet) { return(Ok(RestResult <string> .CreateFailed(errorCode.ToString()))); } Guid purchaseIdentifier = Guid.NewGuid(); CommandResult placeBetResult = _bettingServiceGateway.Execute(new PlaceNormalBetForMultiLegGame { PurchaseIdentifier = purchaseIdentifier, CustomerPlacingBet = _customerServiceGateway.GetBettingReference(GetCustomerBettingInfo(customerKey)), RaceDay = betData.RaceDayKey, Product = betData.BetTypeCode, FirstRaceNumber = betData.RaceNumber, IsFirstPrizeOnlyBet = betData.IsFirstPrizeOnlyBet, LegMarks = betData.Marks.ToDictionary(mark => mark.LegNumber, mark => mark.Marks), RowPrice = Money.FromOere(betData.RowPrice) }); if (!placeBetResult.IsExecuted) { return(Ok(RestResult <string> .CreateFailed(placeBetResult.ErrorCode.ToString(), placeBetResult.Message))); } TicketKey ticketKey = _bettingServiceGateway.GetTicketSerialNumber(purchaseIdentifier); SingleBetItem betItem = _bettingHistoryServiceGateway.GetBetItem(new TicketKey(ticketKey.TicketSerialNumber)); return(Ok(RestResult <PurchaseReceipt> .CreateSuccess(new PurchaseReceipt { TicketSerialNumber = ticketKey.TicketSerialNumber, RaceDay = RaceDayKey.ToString(betData.RaceDayKey), Product = betData.BetTypeCode.ToString(), SellFee = betItem.TicketReceipt.SellFee.Amount, BetCost = betItem.TicketReceipt.BetCost.Amount, PurchaseTime = betItem.TicketReceipt.BetTimeSold }))); }
public ActionResult Invited() { BetData bet = new BetData(); ViewBag.Invitation = false; ViewBag.ActionTypeID = 0; if (RouteData.Values["id"] != null) { int actionTypeID = 0; int.TryParse(RouteData.Values["type"].ToString(), out actionTypeID); ViewBag.Invitation = true; ViewBag.ActionTypeID = actionTypeID; IBetDataRepository _repositoryB = new BetDataRepository(); bet = _repositoryB.Find(new Guid(RouteData.Values["id"].ToString()), actionTypeID); if (bet != null) { ViewBag.TotalVouchers = Convert.ToInt32(bet.Voucher1Value) + Convert.ToInt32(bet.Voucher2Value); } } TempData["BetData"] = bet; if (bet != null) { if (((int)bet.BetStatusID) > 101) { return(RedirectToAction("Index", "Dashboard")); } else { return(View("Invited", bet)); } } else { return(Redirect("~/")); } }
void ReadBetData() { List <string[]> strList; CReadCsvBase.ReaderCsvDataFromAB(GameDefine.CsvAssetbundleName, "Game21BetCsv.txt", out strList); int columnCount = strList.Count; int j; for (int i = 2; i < columnCount; i++) { j = 0; BetData gamedata = new BetData(); int.TryParse(strList[i][j++], out gamedata.m_nMin); int.TryParse(strList[i][j++], out gamedata.m_nKickout); for (int k = 0; k < gamedata.m_nGrades.Length; k++) { int.TryParse(strList[i][j++], out gamedata.m_nGrades[k]); } m_BetData.Add(gamedata); } }
private void EndBetResponce(IAsyncResult asyncResult) { try { var httpResponce = (HttpWebResponse)_httpRequest.EndGetResponse(asyncResult); using (var sr = new StreamReader(httpResponce.GetResponseStream())) { _bd = Deserialize <BetData>(sr.ReadToEnd()); } if (_bd == null || _bd.status != "success") { throw new Exception(); } var bal = GetBalance(); bal.balance = bal.balance * ConvertMultiplier; if (_bd.outcome == "bomb") { OnLoss(bal); } else { OnWin(); } } catch (Exception ex) { _gameIsStop = true; _isError = true; _title = "Failled to place bet"; _message = ex.Message; StopGame(); } }
public ActionResult SupportMePlaceBet(HttpPostedFileBase uplFile) { int amount = 0; Int32.TryParse(Request["hfAmount"], out amount); string name = Request["tbName"]; string email = Request["tbEmail"]; //DO THE MAGIC HERE IUserDataRepository _repositoryU = new UserDataRepository(); UserData user = new UserData(); user = _repositoryU.FindByUsername(email); if (user == null) { user = new UserData(); user.FullName = name; if (String.IsNullOrEmpty(name) || name == null) { user.FullName = email; } user.Email = email; user = _repositoryU.Insert(user); } IBetDataRepository _repositoryB = new BetDataRepository(); BetData bet = new BetData(); bet.Username = User.Identity.Name; bet.User2ID = user.UserID; bet.BetActionID = 115; bet.BetValue = amount; string extension = String.Empty; if (uplFile != null && uplFile.ContentLength > 0) { extension = uplFile.FileName.Substring(uplFile.FileName.IndexOf(".") + 1, uplFile.FileName.Length - uplFile.FileName.IndexOf(".") - 1).ToLower(); bet.FileExtension = extension; } bet = _repositoryB.Insert(bet); if (uplFile != null && uplFile.ContentLength > 0) { int tmpuserID = WebSecurity.GetUserId(User.Identity.Name); var fileName = bet.Guid.ToString() + "_" + tmpuserID + "." + extension;//Path.GetFileName(uplFile.FileName); var path = Path.Combine(Server.MapPath("~/upload/policies/"), fileName); uplFile.SaveAs(path); IFileDataRepository repositoryF = new FileDataRepository(); FileData file = new FileData(); file.BetGuid = bet.Guid; file.FileTypeID = 207; //POLICY file.FileExtension = extension; file.FilePath = path; file.InsertUserID = tmpuserID; repositoryF.Insert(file); } //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, WebSecurity.GetUserId(User.Identity.Name), 115).Add(); string hostName = System.Configuration.ConfigurationManager.AppSettings["HostName"]; string inviteUrl = hostName + "Home/Invited/" + bet.Guid + "/" + bet.BetActionID; string mailBody = "Hi " + name + ",<br><br>"; mailBody += User.Identity.Name + " is hoping you can confirm his driving skills and bet €" + amount.ToString() + " on that.<br><br>"; mailBody += "Join SupportFriend, the social insurance provider and get up to 80% discount on your car insurance, now! <br><br>"; mailBody += inviteUrl; //Code.BasicMailing.SendEmail(email, "", User.Identity.Name + " needs your support on SupportFriend", mailBody); return(Content("<li>" + email + "</li>")); //return RedirectToAction("Index", "Dashboard"); //return View("Support-Me"); }
public ActionResult RegisterPopup(RegisterModel model) { try { Guid id = Guid.Empty; //ČE JE POVABLJEN POBEREMO GUID if (RouteData.Values["id"] != null) { Guid.TryParse(RouteData.Values["id"].ToString(), out id); ViewBag.ID = id; } if (ModelState.IsValid) { // Attempt to register the user try { if (String.IsNullOrEmpty(model.UserName)) { model.UserName = model.Email; } if (!WebSecurity.UserExists(model.UserName)) { WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.Email, FullName = !String.IsNullOrEmpty(model.FullName) ? model.FullName : model.UserName }); } else { WebSecurity.CreateAccount(model.UserName, model.Password); } WebSecurity.Login(model.UserName, model.Password); //POVEŽEMO PRIJATELJA //if(id != Guid.Empty) //{ // IUserDataRepository _repository = new UserDataRepository(); // int userID = WebSecurity.GetUserId(model.UserName); // _repository.AddFriend(userID, id); //} //UPDATEAMO BET if (id != Guid.Empty) { IBetDataRepository _repositoryB = new BetDataRepository(); int userID = WebSecurity.GetUserId(model.UserName); //if (userID == -1) //{ // IUserDataRepository _repositoryU = new UserDataRepository(); // UserData user = new UserData(); // user = _repositoryU.FindByUsername(User.Identity.Name); // userID = user.UserID; //} BetData bet = new BetData(); bet.Guid = id; bet.BetActionID = Convert.ToInt16(RouteData.Values["type"]); if (bet.BetActionID == 115) { bet.User1ID = userID; } else { bet.User2ID = userID; } bet.BetStatusID = Request.QueryString["betStatus"].ToEnum <BetStatus>(); _repositoryB.Update(bet); //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, userID, bet.BetStatusID == BetStatus.Accepted ? 202 : 206).Add(); return(RedirectToAction("Index", "Dashboard")); } //return RedirectToAction("Index", "Bet"); return(RedirectToAction("Support-Me", "Bet")); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return(PartialView("_RegisterPopup", model)); } catch (Exception e) { Neolab.Common.NeoException.Handle(e); return(RedirectToAction("Index", "Error")); } }
public ActionResult LoginPopup(LoginModel model, string returnUrl) { try { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { Guid id = Guid.Empty; //ČE JE POVABLJEN POBEREMO GUID if (RouteData.Values["id"] != null) { Guid.TryParse(RouteData.Values["id"].ToString(), out id); ViewBag.ID = id; } //UPDATEAMO BET if (id != Guid.Empty) { IBetDataRepository _repositoryB = new BetDataRepository(); int userID = WebSecurity.GetUserId(model.UserName); BetData bet = new BetData(); bet.Guid = id; bet.BetActionID = Convert.ToInt16(RouteData.Values["type"]); if (bet.BetActionID == 115) { bet.User1ID = userID; } else { bet.User2ID = userID; } bet.BetStatusID = Request.QueryString["betStatus"].ToEnum <BetStatus>(); _repositoryB.Update(bet); //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, userID, bet.BetStatusID == BetStatus.Accepted ? 202 : 206).Add(); //redirect if (returnUrl != null) { return(RedirectToLocal(returnUrl)); } else { //return RedirectToAction("Index", "Dashboard"); return(RedirectToAction("Index", "Dashboard", new { popup = "typeCredit" + bet.BetID })); } } //return RedirectToAction("Index", "Bet"); //return RedirectToAction("Support-Me", "Bet"); return(Redirect("/Bet/Support-Me")); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return(PartialView("_LoginPopup", model)); } catch (Exception e) { Neolab.Common.NeoException.Handle(e); return(RedirectToAction("Index", "Error")); } }
public ActionResult ExternalLoginCallback(string returnUrl) { try { int tmpUserID = -1; AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl })); if (!result.IsSuccessful) { TempData["Error"] = "Error description: " + result.Error + " " + result.IsSuccessful.ToString(); return(RedirectToAction("ExternalLoginFailure")); } if (OAuthWebSecurity.Login(result.Provider, result.ProviderUserId, createPersistentCookie: false)) { //return RedirectToLocal(returnUrl); tmpUserID = WebSecurity.GetUserId(result.UserName); } if (User.Identity.IsAuthenticated) { // If the current user is logged in add the new account OAuthWebSecurity.CreateOrUpdateAccount(result.Provider, result.ProviderUserId, User.Identity.Name); //return RedirectToLocal(returnUrl); tmpUserID = WebSecurity.GetUserId(result.UserName); } else { // User is new, ask for their desired membership name string loginData = OAuthWebSecurity.SerializeProviderUserId(result.Provider, result.ProviderUserId); ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(result.Provider).DisplayName; ViewBag.ReturnUrl = returnUrl; //return View("ExternalLoginConfirmation", new RegisterExternalLoginModel { UserName = result.UserName, ExternalLoginData = loginData }); RegisterExternalLoginModel model = new RegisterExternalLoginModel { UserName = result.UserName, Email = result.ExtraData["email"], FullName = result.ExtraData["name"], ExternalLoginData = loginData }; string provider = null; string providerUserId = null; if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId)) { return(RedirectToAction("Manage")); } if (ModelState.IsValid) { //Insert a new user into the database using (UsersContext db = new UsersContext()) { UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower()); // Check if user already exists if (user == null) { // Insert name into the profile table //GREGA HACKS -- > model.username v providerUserID //db.UserProfiles.Add(new UserProfile { UserName = model.UserName, UserGuid = Guid.NewGuid(), FullName = model.UserName }); db.UserProfiles.Add(new UserProfile { UserName = model.UserName, UserGuid = Guid.NewGuid(), FullName = model.FullName, Email = model.Email }); db.SaveChanges(); //GREGA HACKS -- > model.username v providerUserID OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName); //???model.Email??? //OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, providerUserId); OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false); tmpUserID = WebSecurity.GetUserId(result.UserName); } else { ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name."); } } } } List <FacebookFriend> friendsList = FacebookDataHelper.GetFriends(); IUserDataRepository _repositoryU = new UserDataRepository(); _repositoryU.AddFBFriends(result.UserName, friendsList); if (tmpUserID != -1) { Guid id = Guid.Empty; if (RouteData.Values["id"] != null) { Guid.TryParse(RouteData.Values["id"].ToString(), out id); } //UPDATEAMO BET if (id != Guid.Empty) { IBetDataRepository _repositoryB = new BetDataRepository(); BetData bet = new BetData(); bet.Guid = id; bet.BetActionID = Convert.ToInt16(RouteData.Values["type"]); if (bet.BetActionID == 115) { bet.User1ID = tmpUserID; } else { bet.User2ID = tmpUserID; } bet.BetStatusID = BetStatus.Accepted; ///!!!!Request.QueryString["betStatus"].ToEnum<BetStatus>(); _repositoryB.Update(bet); //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, tmpUserID, bet.BetStatusID == BetStatus.Accepted ? 202 : 206).Add(); return(RedirectToAction("Index", "Dashboard", new { popup = "typeCredit" + bet.BetID })); } //return RedirectToAction("Index", "Bet"); return(RedirectToAction("Support-Me", "Bet")); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); return(View()); } } catch (Exception e) { Neolab.Common.NeoException.Handle(e); return(RedirectToAction("Index", "Error")); } }
static void DealWiththeBet(string incomingBet, string incomingBettersName, GameObject eachTurtle, TurtleAI turtleScriptRef, RaceManager racemanagerScriptRef, GameObject raceManagerGameObjectRef) { if (incomingBet.CaseInsensitiveContains("win") || incomingBet.CaseInsensitiveContains("show") || incomingBet.CaseInsensitiveContains("place")) { //bet to win string numbersInMessage = Regex.Match(incomingBet, @"\d+").Value; int betAsInt = int.Parse(numbersInMessage); if (betAsInt < 0 || betAsInt > 1000000) { return; } BetData thisBet = new BetData(); thisBet.TurtlesName = eachTurtle.name; thisBet.BetAmount = betAsInt; if (incomingBet.CaseInsensitiveContains("win")) { thisBet.BetType = "win"; turtleScriptRef.howMuchIsBetOnMe += thisBet.BetAmount; } if (incomingBet.CaseInsensitiveContains("place")) { thisBet.BetType = "place"; turtleScriptRef.howMuchIsBetOnMeToPlace += thisBet.BetAmount; } if (incomingBet.CaseInsensitiveContains("show")) { thisBet.BetType = "show"; turtleScriptRef.howMuchIsBetOnMeToShow += thisBet.BetAmount; } thisBet.BettersName = incomingBettersName; thisBet.BetOdds = turtleScriptRef.myRealOdds; foreach (GuestData gD in GuestManager.AllGuests) { if (gD.guestName == thisBet.BettersName) { if (gD.guestCash < thisBet.BetAmount) { thisBet.BetAmount = gD.guestCash; } if (gD.guestCash == thisBet.BetAmount) { GameObject bottomToaster = GameObject.Find("Toaster"); ToasterManager toastScriptRef = bottomToaster.GetComponent <ToasterManager>(); toastScriptRef.ShowAToaster(gD.guestName, " Went ALL IN!"); } gD.guestCash -= thisBet.BetAmount; } } racemanagerScriptRef.CurrentRaceBets.Add(thisBet); TwitchIRC tIRC = raceManagerGameObjectRef.GetComponent <TwitchIRC>(); if (!thisBet.BettersName.Contains("turtlebot")) { string betConfirmedQuip = "Good luck!"; int RandomQuipNumber = Random.Range(0, 10); switch (RandomQuipNumber) { case 0: betConfirmedQuip = "Good luck!"; break; case 1: betConfirmedQuip = "Go Go Go!"; break; case 2: betConfirmedQuip = "Be sure to cheer it on!"; break; case 3: betConfirmedQuip = "It's a lock. KevinTurtle"; break; case 4: betConfirmedQuip = "It's been sandbagging looking for a good spot."; break; case 5: betConfirmedQuip = "Ka-Chow!"; break; case 6: betConfirmedQuip = "They heard their going to break it's maiden. Kappa"; break; case 7: betConfirmedQuip = "It's workouts are unpublished. Kappa"; break; case 8: betConfirmedQuip = "Their UPS driver Lance knows it's owner. Kappa"; break; case 9: betConfirmedQuip = "It's been getting in light because they were using the bug boy on it. Now they're ready to run with it!"; break; case 10: betConfirmedQuip = "It's going to go for a great prize."; break; } tIRC.SendCommand("PRIVMSG #" + tIRC.channelName + " : Bet confirmed. " + thisBet.BettersName + " Bet " + thisBet.BetAmount + " on " + thisBet.TurtlesName + " to " + thisBet.BetType + ". " + betConfirmedQuip); } } }
public ActionResult Respond(bool accept) { IBetDataRepository _repositoryB = new BetDataRepository(); BetData bet = (BetData)TempData["BetData"]; int?userID = null; if (User.Identity.IsAuthenticated) { userID = (int)Membership.GetUser().ProviderUserKey; } if (userID == null) { userID = 0; } //if (userID != null) //sem zlogiran //{ if (bet.BetActionID == 115) //jaz stavim (operiram z User1ID) { if (bet.User1ID == 0) //povabljen sem prek FB { bet.Guid = Guid.Parse(RouteData.Values["id"].ToString()); bet.User1ID = (int)userID; bet.BetStatusID = accept ? BetStatus.Accepted : BetStatus.Rejected; _repositoryB.Update(bet); //update-am bet s svojim ID-jem in statusom //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, (int)userID, accept ? 202 : 206).Add(); } else if (bet.User1ID == userID) //sem logiran in sem povabljen user { bet.Guid = Guid.Parse(RouteData.Values["id"].ToString()); bet.BetStatusID = accept ? BetStatus.Accepted : BetStatus.Rejected; _repositoryB.Update(bet); //update-am bet status //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, (int)userID, accept ? 202 : 206).Add(); } } else if (bet.BetActionID == 114) //nekdo stavi name (operiram z User2ID) { if (bet.User2ID == 0) //povabljen sem prek FB { bet.Guid = Guid.Parse(RouteData.Values["id"].ToString()); bet.User2ID = (int)userID; bet.BetStatusID = accept ? BetStatus.Accepted : BetStatus.Rejected; _repositoryB.Update(bet); //update-am bet s svojim ID-jem in statusom //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, (int)userID, accept ? 202 : 206).Add(); } else if (bet.User2ID == userID) //sem logiran in sem povabljen user { bet.Guid = Guid.Parse(RouteData.Values["id"].ToString()); bet.BetStatusID = accept ? BetStatus.Accepted : BetStatus.Rejected; _repositoryB.Update(bet); //update-am bet status //ZAPIŠEMO HISTORY!!! new EventData(bet.Guid, (int)userID, accept ? 202 : 206).Add(); } } //} //else //{ // return RedirectToAction("Register", "Account", new { id = RouteData.Values["id"], type = RouteData.Values["type"], betStatus = accept ? 102 : 103 }); //preusmerim na registracijo //} if (userID == 0) { return(Redirect("~/")); } else { return(RedirectToAction("Index", "Dashboard", new { popup = "typeCredit" + bet.BetID })); } }
public static void GetABet(string incomingBet, string incomingBettersName, GameObject raceManagerGameObjectRef) { //print("We got a bet: "+ incomingBet); RaceManager racemanagerScriptRef = raceManagerGameObjectRef.GetComponent <RaceManager>(); foreach (GameObject eachTurtle in racemanagerScriptRef.TurtlesInTheRace) { TurtleAI turtleScriptRef = eachTurtle.GetComponent <TurtleAI>(); if (incomingBet.CaseInsensitiveContains("register")) { foreach (GuestData gD in GuestManager.AllGuests) { if (gD.guestName == incomingBettersName) { gD.registeredAddress = incomingBet; } } } if (incomingBet.CaseInsensitiveContains("bid")) { if (incomingBet.CaseInsensitiveContains(" a")) { Debug.Log("incoming bet " + incomingBet); TurtleForSale turtleForBiddingScriptRef = racemanagerScriptRef.CurrentTurtlesForSale[0].GetComponent <TurtleForSale>(); turtleForBiddingScriptRef.GetABid(int.Parse(Regex.Match(incomingBet, @"\d+").Value)); } if (incomingBet.CaseInsensitiveContains(" b")) { Debug.Log("incoming bet " + incomingBet); TurtleForSale turtleForBiddingScriptRef = racemanagerScriptRef.CurrentTurtlesForSale[1].GetComponent <TurtleForSale>(); turtleForBiddingScriptRef.GetABid(int.Parse(Regex.Match(incomingBet, @"\d+").Value)); } if (incomingBet.CaseInsensitiveContains(" c")) { Debug.Log("incoming bet " + incomingBet); TurtleForSale turtleForBiddingScriptRef = racemanagerScriptRef.CurrentTurtlesForSale[2].GetComponent <TurtleForSale>(); turtleForBiddingScriptRef.GetABid(int.Parse(Regex.Match(incomingBet, @"\d+").Value)); } } if (incomingBet.CaseInsensitiveContains(eachTurtle.name) && RaceManager.isBettingOpen) { //bet on the turtle //print("Bet on this turtle " + eachTurtle.name); if (incomingBet.CaseInsensitiveContains("win") || incomingBet.CaseInsensitiveContains("show") || incomingBet.CaseInsensitiveContains("place")) { //bet to win string numbersInMessage = Regex.Match(incomingBet, @"\d+").Value; int betAsInt = int.Parse(numbersInMessage); if (betAsInt < 0) { return; } BetData thisBet = new BetData(); thisBet.TurtlesName = eachTurtle.name; thisBet.BetAmount = betAsInt; if (incomingBet.CaseInsensitiveContains("win")) { thisBet.BetType = "win"; turtleScriptRef.howMuchIsBetOnMe += thisBet.BetAmount; } if (incomingBet.CaseInsensitiveContains("place")) { thisBet.BetType = "place"; turtleScriptRef.howMuchIsBetOnMeToPlace += thisBet.BetAmount; } if (incomingBet.CaseInsensitiveContains("show")) { thisBet.BetType = "show"; turtleScriptRef.howMuchIsBetOnMeToShow += thisBet.BetAmount; } thisBet.BettersName = incomingBettersName; thisBet.BetOdds = turtleScriptRef.myRealOdds; foreach (GuestData gD in GuestManager.AllGuests) { if (gD.guestName == thisBet.BettersName) { if (gD.guestCash < thisBet.BetAmount) { thisBet.BetAmount = gD.guestCash; } if (gD.guestCash == thisBet.BetAmount) { GameObject bottomToaster = GameObject.Find("Toaster"); ToasterManager toastScriptRef = bottomToaster.GetComponent <ToasterManager>(); toastScriptRef.ShowAToaster(gD.guestName, " Went ALL IN!"); } gD.guestCash -= thisBet.BetAmount; } } racemanagerScriptRef.CurrentRaceBets.Add(thisBet); TwitchIRC tIRC = raceManagerGameObjectRef.GetComponent <TwitchIRC>(); if (!thisBet.BettersName.Contains("turtlebot")) { tIRC.SendMsg("Confirmed: " + thisBet.BettersName + " Bet " + thisBet.BetAmount + " on " + thisBet.TurtlesName + " to " + thisBet.BetType); } //tIRC.SendCommand(".PRIVMSG #turtleracingalpha :/w turtleracingalpha this is a whisper with ."); //tIRC.SendCommand("/PRIVMSG #turtleracingalpha :/w turtleracingalpha this is a whisper with /"); //tIRC.SendCommand(":PRIVMSG #turtleracingalpha :/w turtleracingalpha this is a whisper with :"); //tIRC.SendMsg("/w turtleracingalpha this is a whisper with msg"); //Debug.Log("For <color=green>" + thisBet.BetAmount + "</color> at odds of " + thisBet.BetOdds); } } } }
private List <BetData> ConvertJsontoObject(string Str) { List <BetData> BetData = new List <BetData>(); string LeagueName; Event Eventdata; Odds Oddsdata; OddPers OddsPerdata; string JsonStr = Str; //แปลง Json ให้พร้อมใช้งาน JsonStr = JsonStr.Replace("1x2", "onextwo").Replace("\"", "\\"); JsonStr = JsonStr.Replace(@"\1\", @"\one\").Replace(@"\2\", @"\two\").Replace("\\", "\""); JsonStr = JsonStr.Replace(@"888sport", @"eeesport"); JsonStr = JsonStr.Replace(@"1xbet", @"onexbet"); //Convert Json to object var ObjectOdds = JsonConvert.DeserializeObject <List <RootObject> >(JsonStr); foreach (var eachobject in ObjectOdds) { LeagueName = ""; Eventdata = null; Oddsdata = null; OddsPerdata = null; if (eachobject.Sites.onextwo != null) //เลือกเฉพาะตัวที่มีราคาต่อรองแล้ว { //IF have League if (eachobject.League.name != null) { LeagueName = eachobject.League.name; } //IF have Event if (eachobject.Event != null) { Eventdata = eachobject.Event; } //IF have Odds if (eachobject.Sites.onextwo != null) { if (eachobject.Sites.onextwo.bet365 != null) { Oddsdata = eachobject.Sites.onextwo.bet365.odds; } else if (eachobject.Sites.onextwo.sbobet != null) { Oddsdata = eachobject.Sites.onextwo.sbobet.odds; } else if (eachobject.Sites.onextwo.eeesport != null) { Oddsdata = eachobject.Sites.onextwo.eeesport.odds; } else if (eachobject.Sites.onextwo.betfair != null) { Oddsdata = eachobject.Sites.onextwo.betfair.odds; } else if (eachobject.Sites.onextwo.interwetten != null) { Oddsdata = eachobject.Sites.onextwo.interwetten.odds; } else if (eachobject.Sites.onextwo.onexbet != null) { Oddsdata = eachobject.Sites.onextwo.onexbet.odds; } //IF have Odds --> Set percent win-lose-draw rate if (Oddsdata != null) { var item2 = new OddPers { OnePer = (Oddsdata.two * 100) / (Oddsdata.one + Oddsdata.two + Oddsdata.X), TwoPer = (Oddsdata.one * 100) / (Oddsdata.one + Oddsdata.two + Oddsdata.X), XPer = (Oddsdata.X * 100) / (Oddsdata.one + Oddsdata.two + Oddsdata.X) }; OddsPerdata = item2; } } //Add data into list for send back to front-end var item = new BetData { League = LeagueName, Event = Eventdata, odds = Oddsdata, OddsPers = OddsPerdata }; BetData.Add(item); } } return(BetData); }