Skip to content

ArchaicDamsel/nrug-battlecritters

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
app
 
 
bin
 
 
 
 
db
 
 
 
 
lib
 
 
log
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README

Request Team

The first step is to register your intention to play. You do this with the following request:

GET /apis

Possible response statuses:

  • 200 - Successful request.

  • 500 - Error - there are probably already two players on the server.

Server should return something similar to the following JSON:

{ “animal”: “fox”, “board”: [8,8], “pieces”: [5,4,3,2,1] }

Though if it fails, you’ll receive a message like this:

{ “result”: “Too late: Sorry someone has beat you to it” }

Position Pieces

A JSON object containing two arrays needs to be sent back to the server:

  • vertical: list of pieces oriented vertically

  • horizontal: list of pieces oriented horizontally

Note: you will be responsible for ensuring that all pieces are placed, and that no pieces overlap. If you fail to do this, the server will reject your request and the other team will win by default

Note: both vertical and horizontal arrays must be defined, but may be empty.

You can send your list of positions with the following request:

POST /apis/:animal

The request needs to post the following params: { :animal => :my_animal, :positions => { “vertical”: [[piece, x, y], [piece, x, y], …], “horizontal”: [[piece, x, y], [piece, x, y], …] } } }

… where ‘piece` is a number 1 to 5 according to its size (for example, piece number five is the largest piece on the board spanning five squares).

Possible response statuses:

  • 200 - Successful placement

  • 500 - Error - probably because of overlapping pieces, or not all pieces being placed. Don’t bother making any more requests - you’ve lost.

Place your pieces wisely and the result will be JSON such as:

{ “result”: “Success: You are ready to play!” }

Explaination

The board’s axises are labelled X and Y - where [0,0] is the top left square (see figure .1) . X and Y in the array are the co-ordinates of the first square of your piece starting with the highest or leftmost corner (depending on its orientation)(see figure .2).

figure .1

y axis

0___1___2___3___4___5___6___7 0| + | | | | | | | | ——————————— 1| | | | | | | | | ——————————— x 2| | | | | | | | | ——————————— a 3| | | | | | | | | x ——————————— i 4| | | | | | | | | s ——————————— 5| | | | | | | | | ——————————— 6| | | | | | | | | ——————————— 7| | | | | | | | | _

  • + marks the square at (0,0)

figure .2

y axis

0___1___2___3___4___5___6___7 0| | | | | | | | | ——————————— 1| | | | + | | | | | ——————————— x 2| | | | + | | # | # | # | ——————————— a 3| | | | + | | | | | x ——————————— i 4| | | | + | | | | | s ——————————— 5| | | | + | | | | | ——————————— 6| | | | | | | | | ——————————— 7| | | | | | | | | _

  • + marks the position for a vertical piece 5 in starting co-ordinates (1,3).

  • # marks the position for a horizontal piece 3 in starting co-ordinates (2,5).

Shooting

A JSON array containing your shooting co-ordinates for each shot is required.

You do this with the following request:

PUT /apis

Your code should produce an infinite string of co-ordinates for each shot of your game strategy. Each shot should be sent to the server singularly in params as follows:

{ :animal => :my_animal, :shot => [x, y] }

As above X and Y are the the co-ordinates and refer to the squares on the board.

Possible response statuses:

  • 200 - Successful shot

  • 500 - Error - probably because you’ve already lost or won.

The response from the server should be as follows:

{ “result”: “hit” }

The result will be one of the following

  • miss - you may have some angry moles on your hands, but no damage to your opponent

  • hit - you hit an enemy’s home. There they were, eating dinner, a massive missile crashed through their roof. I hope you’re proud.

  • win - you win! Take home a cuddly toy. (note: no cuddly toys. Sorry.)

  • lose - sorry, you lost.

#* destroy - you have sunk their battleship. Erm, I mean destroyed the enemy target.

Note: There is currently no indication whether you “sunk” their “battleship”. You will have to explore all the edges of an enemy to be sure.

Once all oppositions pieces have been destroyed the server will return the winner.

FAQs:

* Why are you using /apis rather than /api? Because rails is a meanie. There is probably a way to fight rails and force a singular controller name throughout, and still have access to create and index actions, but to be honest I couldn’t be bothered.

* What happens if I shoot at the same point repeatedly? Uhhh, other than giving the opposition the advantage? Absolutely nothing. The same response will be returned each time.

* Do I have to do this TDD-style? That would be preferred. But I’m not your mother. If I was your mother, I might tell you to stop shooting poor defenceless badgers. If I was my mother, I would help you skin the badger and boil up a tasty badger soup though, so your milage may vary.

I would tell you a kitten dies for every untested line of code, but you’re the kind of person to murder badgers in their sleep, so I doubt that would do much.

* There’s a piece with size of 1 - WTF?!? Hah! Well, some animals prefer the solitary life. And we’re sadistic. Go figure.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published