Hello,
I am trying to make a text based strategy game. The rules for the game are here [url]http://www.mrsticky005.com/Conquer.html
This is what I’ve got going so far [url]http://www.mrsticky005.com/PlayConquer.html
Obviously I did not create the code for the chat.
I apologize in advance if I’m really really slow when it comes to this sort of stuff. Of course there are tutorial sites
but the problem is I don’t even know what I should be looking for.
Specifically what I want to know is how can I click on say the ocean button and get it so where it says location that it would show which ocean I was randomly selected for?
Obviously I did not create the code for the chat. [/QUOTE]Did you google for "php free chat download"? This finds a lot of chat scripts, e. g. this:
Did you google for "php free chat download"? This finds a lot of chat scripts, e. g. this:
http://www.pcpin.com/
which seems to meet your requirements.[/QUOTE]
Obviously I did not create the code for the chat.[/QUOTE]I understood it in that way that you have no code yet!
15 Errors, 4 warning(s)
https://validator.w3.org/check?uri=http%3A%2F%2Fwww.mrsticky005.com%2FPlayConquer.html&charset=%28detect+automatically%29&doctype=Inline&group=0 [/QUOTE]
I want to click "Atlantic Fishing $5" and have it deduct from the gold.[/QUOTE]Don't understand: Where is the gold? I only find a string "Gold" in the Stats box.
Don't understand: Where is the gold? I only find a string "Gold" in the Stats box.[/QUOTE]
your starting $50[/QUOTE]Cannot find this. Close to "Gold" in the Stats box nothing is displayed.
Cannot find this. Close to "Gold" in the Stats box nothing is displayed.[/QUOTE]
Cannot find this. Close to "Gold" in the Stats box nothing is displayed.[/QUOTE]
It makes your code difficult to handle when you have seven javascript files. Concentrate them in one file.
You need only one function getRandomWord() when you pass the array as a parameter.
And give meaningful names to your functions.[/QUOTE]
What do you mean by "pass the array as a parameter"?[/QUOTE]Define and call the function like this:
[CODE]var getRandomWord = function (words) {
return words[Math.floor(Math.random() * words.length)];
};
var word1 = getRandomWords(words1);
var word2 = getRandomWords(words2);[/CODE]
Well I tried concentrating it all in one file and now none of it works. So I dunno.[/QUOTE]Try it again and put it online. I will have a look at it. You may create a second page if you don't want to have a non working one online.
[CODE]var stats = {gold: 0, fish: 0, nothing: 0};
// extend this object according your needs
var dataAtlanticFishing = [
{text: "You rolled a 1 and got Gold x 1", type: "gold", amount: +30},
{text: "You rolled a 2 and got Fish x 1", type: "fish", amount: +15},
// and so on
{text: "You rolled a 12 and got Nothing," type: "nothing", amount: 0)
];
// define data for other sets of words
function processClick(data, id) {
cData =data[Math.floor(Math.random() * data.length)];
document.getElementById(id).textContent = cData.text;
stats[cData.type] += cData.amount;
document.getElementById("balance-" + cData.type).value = balances[cData.type];
};[/CODE]
[code=html]// button as you have it already:
<button onclick='processClick(dataAtlanticFishing, "text-AtlanticFishing")'>Atlantic Fishing $5</button>
// Text is displayed here:
<p id="text-AtlanticFishing"></p>
// Stats containing balance. Not shure whether the balance for fish
// should be separate by oceans
Gold:<input type="text" id="balance-gold">
Fish: <input type="text" id="balance-fish">[/code]
If I read the code correctly, this should do the job:
Javascript:
[CODE]var stats = {gold: 0, fish: 0, nothing: 0};
// extend this object according your needs
var dataAtlanticFishing = [
{text: "You rolled a 1 and got Gold x 1", type: "gold", amount: +30},
{text: "You rolled a 2 and got Fish x 1", type: "fish", amount: +15},
// and so on
{text: "You rolled a 12 and got Nothing," type: "nothing", amount: 0)
];
// define data for other sets of words
function processClick(data, id) {
cData =data[Math.floor(Math.random() * data.length)];
document.getElementById(id).textContent = cData.text;
stats[cData.type] += cData.amount;
document.getElementById("balance-" + cData.type).value = balances[cData.type];
};[/CODE]
HTML:
[code=html]// button as you have it already:
<button onclick='processClick(dataAtlanticFishing, "text-AtlanticFishing")'>Atlantic Fishing $5</button>
// Text is displayed here:
<p id="text-AtlanticFishing"></p>
// Stats containing balance. Not shure whether the balance for fish
// should be separate by oceans
Gold:<input type="text" id="balance-gold">
Fish: <input type="text" id="balance-fish">[/code]
Try to integrate this into your page and if it doesn't work, come back.
I didn't test the code as I didn't implement the complete game.[/QUOTE]
[CODE] {text: "You rolled a 12 and got Nothing," type: "nothing", amount: 0)[/CODE]
[CODE] {text: "You rolled a 12 and got Nothing", type: "nothing", amount: 0)[/CODE]
No, at the current state it wasn't you who messed it up but I made a mistake. This line in conquer7.js is faulty:
[CODE] {text: "You rolled a 12 and got Nothing," type: "nothing", amount: 0)[/CODE]
The comma after "got Nothing" is misplaced. This is correct:
[CODE] {text: "You rolled a 12 and got Nothing", type: "nothing", amount: 0)[/CODE]
The purpose of the variable stats is to keep the values of the Stats box. So far I understood the game in that way that the amount of gold, fish etc. is summarized in that box. Correct me if I'm wrong.[/QUOTE]
[CODE]var stats = {gold: 50, fish: 0, hp:10, nothing: 0};
// extend this object according your needs
var dataAtlanticFishing = [
{text: "You rolled a 1 and got Gold x 1", type: "gold", amount: +30},
{text: "You rolled a 2 and got Fish x 1", type: "fish", amount: +15},
// and so on
{text: "You rolled a 12 and got Nothing," type: "nothing", amount: 0)
];
// define data for the other oceans
function doFishing(data, id, cost) {
stats.gold -= cost;
cData =data[Math.floor(Math.random() * data.length)];
document.getElementById(id).textContent = cData.text;
stats[cData.type] += cData.amount;
document.getElementById("balance-" + cData.type).value = balances[cData.type];
};[/CODE]
[code=html]// button as you have it already:
<button onclick='doFishing(dataAtlanticFishing, "text-AtlanticFishing", 5)'>Atlantic Fishing $5</button>
// Text is displayed here:
<p id="text-AtlanticFishing"></p>
// Stats containing balance.
Gold:<input type="text" id="balance-gold">
Fish: <input type="text" id="balance-fish">
Health Points: <input type="text" id="balance-hp">[/code]
Completing this code you can code the fishing procedure by using only one function doFishing().0.1.9 — BETA 5.24