# Help with Web Game

**URL:** <https://www.ruby-forum.com/t/help-with-web-game/193551>\
**Category:** Rails\
**Created:** [August 19, 2010, 4:05pm UTC](https://www.ruby-forum.com/t/help-with-web-game/193551 "2010-08-19T16:05:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jooma2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@jooma2](https://www.ruby-forum.com/u/jooma2)\
**Post date:** [August 19, 2010, 4:05pm UTC](https://www.ruby-forum.com/t/help-with-web-game/193551/1 "2010-08-19T16:05:24Z")

</div>

Hello.

I worked with Ruby on Rails professionally for a little under a year,  
but then got a new job and have been a flash developer for the last 2.5  
years.  
So I’m extremely rusty with Rails.

What I’m doing: I want to make a small browser text based RPG  
with the option to use flash. (So people can play at work).

The Focus: Ideally I’d like people to be able to control their  
actions in the fight instead of just reading through the log of their  
auto attacks after.  
I’m thinking you can have 8 slots to remember spells/abilities to be  
able to use while in combat. Kind of like old school EverQuest.

The Problem: I want to include PVP as an option. So if you’re in  
a zone and you see in your /who list another player from the opposed  
faction, you can choose to attack them. But how do I implement this so  
they can join in turn based combat? I was looking at Smartfox Server  
lite, but this is just a project for friends and friends of friends. I’m  
with HostGator and I really don’t think I can install something like  
Smartfox on the shared hosting server.

Also for Chat, I was thinking of just having a database that stored the  
last 30 or so entries and updated them on refresh. Is there a better way  
to implement that on a shared hosting server?

Any ideas or theories would be really appreciated. If I can’t find a  
solution I may have to change up how combat works so that you just  
manage the AI of your character and when to use their spells. Something  
like in Dragon Age.

---

<div class="post-metadata">

**Author:** ![jooma2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@jooma2](https://www.ruby-forum.com/u/jooma2)\
**Post date:** [August 19, 2010, 7:57pm UTC](https://www.ruby-forum.com/t/help-with-web-game/193551/2 "2010-08-19T19:57:34Z")

</div>

On Aug 19, 10:05 am, Jooma \_\_ [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to implement that on a shared hosting server?  
> I think at the very least, you’ll need to use a Xen-based VPS where  
> you get root access, such as a Rackspace Cloud server.

I’d look at messaging/queuing options, such as Jabber/XMPP or AMQP  
implementations. That’d work for both managing a turn-based combat as  
well as chat. You’d write it like the old MUDs. If you’re willing to  
sacrifice HTML4 support, you can try the Websocket stuff in HTML5 and  
require all players to install browsers that support it (such as  
Chrome and Safari).

I wouldn’t try using a browser-refresh scheme written using Rails; a  
background process at the very least or a separate server using

> **[Introducing Phat, an Asynchronous Rails app | Mike Perham](http://www.mikeperham.com/2010/04/03/introducing-phat-an-asynchronous-rails-app/)**
>
> Ruby, OSS and the Internet

, or even using Node.js for the server-side. The Rails side would work  
well if you take advantage of REST to describe resources (such as,  
descriptions of game objects and user avatars), but not specifically  
to manage the combat (ephemeral, state-ful, evented system vs. the  
shared-nothing, stateless system that Rails and the Web is based on).  
So I think Redis works better than a SQL db for handling the combat  
states itself.

The downside is that this starts getting pretty intricate. The beauty  
of the auto-combat system in current web-browser games is that they  
give the _llusion_ of control, which is enough for most players (see  
[Creating the illusion of accomplishment - Wolfire Games Blog](http://blog.wolfire.com/2009/07/creating-the-illusion-of-accomplishment/)).  
If you implement AIs as part of the gameplay, I suggest looking at  
making its perceived user control of the new system match the  
perceived user control of the old system.

Good luck.

Ho-Sheng H.

> **[lambda { }](http://ruby-lambda.blogspot.com/)**
>
> lambda { put(self).in(:pipe).and.call() }

---

<div class="post-metadata">

**Author:** ![jooma2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@jooma2](https://www.ruby-forum.com/u/jooma2)\
**Post date:** [August 19, 2010, 8:26pm UTC](https://www.ruby-forum.com/t/help-with-web-game/193551/3 "2010-08-19T20:26:15Z")

</div>

Thank you so much for replying.

A lot of that was far over my head. But the mention of HTML5 Web sockets  
was something I was unaware. I could easily force my userbase to use  
HTML5 as it’s just going to be friends. There won’t be any profiting in  
this project at all. Just something fun for maybe 10-20 people to do.

---

<div class="post-metadata">

**Author:** ![jooma2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e9bcb4/32.png) [@jooma2](https://www.ruby-forum.com/u/jooma2)\
**Post date:** [August 21, 2010, 12:03am UTC](https://www.ruby-forum.com/t/help-with-web-game/193551/4 "2010-08-21T00:03:34Z")

</div>

You can do a lot with HTML5:

> **[Google Shows How HTML5 Can Run Quake In The Browser](https://techcrunch.com/2010/04/01/google-html5-quake/)**
>
> A lot of attention lately has been put on the video capabilities of HTML5 browsers, since the iPad doesn't support Flash. It turns out not to really matter that much because most online video platforms are now drinking the HTML5 Kool-Aid. But what...

> **[bullet.js - Javascript Ragdoll Physics](http://pl4n3.blogspot.com/2010/07/bulletjs-javascript-ragdoll-physics.html)**
>
> I ported more classes from JBullet to Javascript Physics engine bullet.js , wrote some new and assembled a new canvas demo showing javascrip...

and it has the advantage of letting you put together an app for the  
iPhone/iPad while bypassing Apple’s requirements for AppStore.

When Chrome beta first came out and I heard it had the ability to  
create app shortcuts on the desktop, I realized you could package a  
web game in what appears to be a desktop app. The installer would just  
check if Chrome is available and if not, it’d download it for you.

Chrome comes with Google Gears, so you can use a local SQL store,  
though I’m not sure how well that’d work with your game. Maybe as a  
cache.

I’d like to talk to you more about the game off this list/forum. Using  
Rails to write a web-based turn-based game has been something I’ve  
been messing with in my head for a while.

Ho-Sheng H.
