玩家滑动即可删除比赛 [英] Player swipe to remove match

查看:71
本文介绍了玩家滑动即可删除比赛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有两名玩家进行回合制比赛.在某个时候,玩家1意识到他将要输掉比赛.轮到玩家1时,他使用Game Center App滑动来删除比赛.

Let's say I have a turn based match with two players. At some point player 1 recognizes that he is about to lose the game. When it is Player 1's turn, he uses Game Center App to do a swipe to remove the match.

问题:

A.轮到计时器永远不会在玩家1上过期.因此,时间到后,比赛的轮到不会切换到玩家2上.

A. Take turn timer never expires on Player 1. So the match's turn will not switch to Player 2 when the time expired.

B.游戏还提供了仅查看模式,因此玩家可以在转弯时查看游戏进度.但是由于没有状态被更新以指示玩家1已经手动删除了比赛.应用程式无法提供解析度.另外,轮到您时才可以结束比赛.

B. The game also offers a view only mode so players can view the game progress while he is out of turn. But since no status was updated to indicate that Player 1 had removed the match manually. App can offers no resolution. Also, you can only end match while it is your turn.

理想情况下,我想宣布玩家2为获胜者并结束比赛.

Ideally, I want to declare Player 2 as a winner and end the match.

在这种情况下如何处理?

How do you handle in this situation?

推荐答案

我终于找到了解决方法.

I finally found a workaround for this.

如果删除一个匹配项,然后调用GKTurnBasedMatch:loadMatchesWithCompletionHandler,则删除的匹配项不会出现(按预期).但是,事实证明,如果您碰巧仍具有删除的匹配的ID,您仍可以 使用GKTurnBasedMatch:LoadMatchWithID重新下载删除的匹配.

If you delete a match, then call GKTurnBasedMatch:loadMatchesWithCompletionHandler, the deleted match doesn't appear (as expected). However, it turns out that you can still re-download the deleted match using GKTurnBasedMatch:LoadMatchWithID, if you happen to still have the deleted match's ID.

我认为我们可以合理地认为The Cheater将再次玩游戏;否则,他们为什么会担心遭受损失?因此,我实现了以下内容:

I think we can reasonably assume that The Cheater is going to play the game again; otherwise, why would they care about incurring a loss? Therefore, I implemented the following:

  1. 在设备上本地保存匹配表.
  2. 启动时,从Game Center中提取本地玩家的比赛列表,并与我的本地列表进行比较.

当作弊者识别出这种情况并使用Game Center界面删除了比赛时,该比赛将从Game Center中删除,但不会从我的本地数据库中删除.当The Cheater再次开始我的游戏时,我发现他们在本地的比赛比在Game Center上的比赛多.

When The Cheater recognizes the situation and deletes the match using the Game Center interface, the match is removed from Game Center, but not from my local DB. When The Cheater starts my game again, I see that they have more matches locally than on Game Center.

然后我根据需要调用participantQuitInTurnWithOutcomeparticipantQuitOutOfTurnWithOutcome,结果为GKTurnBasedMatchOutcomeLost.

I then call either participantQuitInTurnWithOutcome or participantQuitOutOfTurnWithOutcome, as appropriate, with an outcome of GKTurnBasedMatchOutcomeLost.

这将回合转到下一个玩家,并记录了The Cheater的损失.但是,如果作弊者再也不玩游戏了,那将是行不通的. (但是,如果他们不参加比赛,他们就不会破坏比赛,因此就可以避免混乱)

This passes the turn to the next player and records a loss for The Cheater. It won't work if the cheater never plays the game again, though. (But, if they're not playing, they're not wrecking any more matches, so the chaos is contained)

这篇关于玩家滑动即可删除比赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆