使用 .NET 和 Asp.NET MVC 后端开发 HTML5 扑克应用程序的正确方法是什么?

发布于 2024-12-17 03:28:40 字数 259 浏览 2 评论 0原文

我想开发一个带有.net 和 Asp.Net MVC 后端的 HTML5 扑克游戏。我想了解的是应用程序中有很多部分需要随时刷新。

这是一个示例场景: 假设有一张活跃的扑克桌。玩家必须在 20 秒内决定要做什么(跟注、过牌、弃牌等)。玩家A决定在第10秒投入所有筹码。其他所有玩家如何才能看到玩家 A 在第 10 秒决定全押?

我想问的是,如何填充有关扑克游戏、牌桌、用户的所有信息?我需要学习 HTML5 的概念和 API 是什么?

感谢您的帮助...

i would like to develop a HTML5 poker game with .net and Asp.Net MVC backend. What i would like to learn is that there are a lot of sections in the application that needs to be refreshed all the time.

Here is a sample scenario :
Let's assume there's an active poker table. Players must decide what to(call, check, fold, etc.) in 20 seconds. Player A decided to put all his chip in 10th second. How can all the other players see that the Player A has decided to all-in in 10th second?

What i'm trying to ask is that how can i populate all the informations about the poker games, tables, users? What are the concepts, APIs i need to learn about HTML5?

Thanks for your help...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海拔太高太耀眼 2024-12-24 03:28:40

这里有一些不同的解决方案:

要么让客户端定期检查新信息,要么将信息推送给他们,我会推荐后一个选项,因为您要使用 HTML5。

为了将信息推送到客户端,您需要与它们建立开放的连接,建议使用 HTML5 Web Sockets 来实现这一点。

在游戏过程中,它可能看起来像这样:

  1. 客户端连接到服务器并加入一个表。

  2. 当客户端加入桌子时,他会从服务器请求有关其他玩家的信息(姓名、位置等)和当前状态。

  3. 当玩家做出举动时,他将“Raise $10”推送到服务器,服务器检查此举动是否有效(轮到玩家,玩家有足够的资金等),如果举动有效则服务器向所有其他玩家推送该玩家采取的行动,这是桌子的当前状态。

如果您要使用套接字解决方案,您可能必须用 C# 编写一个“套接字服务器”解决方案才能进行实际的游戏。但它将是对 MVC 的补充,因为 MVC 将处理所有 HTML 内容。

有关 Web 套接字的更多内容:

入门教程

专门用于 Web Sockets 的站点

兼容性表

You got a few diffrent solutions here:

Either you make the clients check for new information in intervalls or you push the information to them, I would recommend the later option since you are going for HTML5.

In order to push the information to the clients you will need to have an open connection to them, would recommend HTML5 Web Sockets to achieve that.

It will probably look something like this during the game play:

  1. An client connects to the server and joins an table.

  2. When the client joins the table he requests information about the other players from the server (name, positions etc) and current status.

  3. When a player makes a move, he pushes "Raise $10" to the server, the server checks if this move is valid (it is the players turn, the player got enough funds etc), if the move is valid the severs pushes out to all other players that the player made the move and this is the current status of the table.

You will probably have to write a "socket server" solution in C# for the actual game play if you are going for the socket solution. But it will be in addition to MVC since MVC will handle all the HTML stuff around.

Some more to read about Web Sockets:

Beginner tutorial

Site dedicated to Web Sockets

Compatibility table

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文