public void Save() { WordSet wordSet = GameController.Instance.GetWordSet(); var puzzle = new UserPuzzle { Clue = wordSet.Clue, Content = StringCompressor.CompressString(JsonUtility.ToJson(wordSet)) }; LocalDBController.Instance.UserPuzzles.AddPuzzle(puzzle); }
public void AddPuzzle(UserPuzzle puzzle) { var userPuzzles = LocalDBController.Table <UserPuzzle>().ToList(); if (userPuzzles.Count > 0) { puzzle.ID = userPuzzles.Max(p => p.ID) + 1; } else { puzzle.ID = 1; } LocalDBController.InsertOrReplace(puzzle); }
public IEnumerator SetForSpawn(int ID) { UserPuzzle selectedPuzzle = null; _pID = ID; // Ask command center to connect to account /* * yield return ServerController * .Get<UserPuzzle>($@"UserPuzzles/{ID}", * puzzle => { selectedPuzzle = (UserPuzzle)puzzle; }); */ ServerRespond = null; yield return(ServerController .Post <string>($@"UserPuzzles/GetInviteData?puzzleID={ID}&senderID={Singleton.Instance.PlayerController.PlayerID}", null, r => { ServerRespond = JObject.Parse(r); }, request => { FollowMachine.SetOutput("Fail"); } )); if (ServerRespond == null) { FollowMachine.SetOutput("Fail"); yield break; } var json = StringCompressor.DecompressString(ServerRespond["Content"].ToString()); WordSet wordSet = new WordSet(); JsonUtility.FromJsonOverwrite(json, wordSet); Singleton.Instance.WordSpawner.WordSet = wordSet; Singleton.Instance.WordSpawner.Clue = ServerRespond["Clue"].ToString(); Singleton.Instance.WordSpawner.PuzzleID = -1; Singleton.Instance.WordSpawner.PuzzleRow = ServerRespond["Creator"].ToString(); Singleton.Instance.WordSpawner.EditorInstatiate = null; FollowMachine.SetOutput("Success"); }
public void UpdatePuzzles(IEnumerable <IUpdatedUserPuzzle> updatedUserPuzzles) { foreach (var puzzleUpdate in updatedUserPuzzles) { var puzzle = new UserPuzzle { ID = puzzleUpdate.ID, ServerID = puzzleUpdate.ServerID, Clue = puzzleUpdate.Clue, Rate = puzzleUpdate.Rate, Content = puzzleUpdate.Content, PlayCount = puzzleUpdate.PlayCount, CategoryName = puzzleUpdate.CategoryName }; LocalDBController.InsertOrReplace(puzzle); } }
/// <summary> /// 完成拼图结果 /// </summary> /// <returns>操作结果 提示语句 是否绑定平台活动 平台活动名 绑定地址</returns> public Tuple <bool, string, bool, string, string> Complete(string unid) { var user = CookieHelper.GetCurrentWxUser(); var person = CookieHelper.GetCurrentPeople(); if (user == null || person == null) { return(new Tuple <bool, string, bool, string, string>(false, "身份过期", false, "", "")); } using (DbRepository entities = new DbRepository()) { var puzzle = entities.Puzzle.Find(unid); if (puzzle == null) { return(new Tuple <bool, string, bool, string, string>(false, "参数错误", false, "", "")); } var dateTime = DateTime.Now.Date; if (entities.UserPuzzle.FirstOrDefault(x => x.PuzzleId.Equals(unid) && x.PuzzleDate == dateTime) != null) { return(new Tuple <bool, string, bool, string, string>(false, "该拼图已玩过", false, "", "")); } var userPuzzle = new UserPuzzle() { UNID = Guid.NewGuid().ToString("N"), OpenId = user.openid, PuzzleDate = dateTime, PuzzleId = unid }; entities.UserPuzzle.Add(userPuzzle); if (puzzle.IsBindScore == (int)YesOrNoCode.Yes) { //日常签到积分 var scoreDetials = new ScoreDetails() { UNID = Guid.NewGuid().ToString("N"), OpenId = user.openid, CreatedTime = DateTime.Now, Description = "完成拼图获得积分", IsAdd = (int)YesOrNoCode.Yes, Value = puzzle.Score, Type = (int)ScoreType.Puzzle, PersonId = person.UNID, TargetId = unid }; entities.ScoreDetails.Add(scoreDetials); //用户积分增加 var updateUserScore = entities.UserScore.FirstOrDefault(x => x.OpenId.Equals(user.openid) && x.PersonId.Equals(person.UNID)); if (updateUserScore == null) { var addUserScore = new UserScore() { UNID = Guid.NewGuid().ToString("N"), OpenId = user.openid, PersonId = person.UNID, Score = puzzle.Score }; entities.UserScore.Add(addUserScore); } else { updateUserScore.Score += puzzle.Score; } return(entities.SaveChanges() > 0?new Tuple <bool, string, bool, string, string>(true, string.Format("恭喜你获得:{0}积分", puzzle.Score), false, "", ""):new Tuple <bool, string, bool, string, string>(false, "保存出错", false, "", "")); } else { return(entities.SaveChanges() > 0?new Tuple <bool, string, bool, string, string>(true, puzzle.BindTitle, true, puzzle.BindName, puzzle.BindUrl): new Tuple <bool, string, bool, string, string>(false, "保存出错", false, "", "")); } } }
static object lastSeen(UserPuzzle userPuzzle) => Ut.NewArray <object>( "😎 ", userPuzzle == null ? "—" : userPuzzle.SolveTime.Year == 1900 ? "(not recorded)" : userPuzzle.SolveTime.ToString("d MMM yyyy, H:mm"));
static object solveTime(UserPuzzle userPuzzle) => userPuzzle == null ? "🕛 —" : new[] { "🕛🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚".Substring(userPuzzle.Time / 60 % 60 / 5 * 2, 2), " ", formatTime(userPuzzle.Time) };
public UserPuzzle Refresh(UserPuzzle puzzle) { return(LocalDBController.Table <UserPuzzle>() .FirstOrDefault(p => p.ID == puzzle.ID)); }
public IEnumerator ShareUserPuzzle(UserPuzzle userPuzzle) { throw new System.NotImplementedException(); }