Click to See Complete Forum and Search --> : Can Somebody Please Tell Me How To Script This


Dick Withem
02-11-2003, 06:43 PM
Can someone tell me how I might go about scripting this??



I would like to make a js to do the following, however my scripting skills are not good enough yet to accomplish it. I would really appreciate it if someone could help me...


Here is what I am trying to do... I am trying to calculate different betting results for the card game "WAR" it is a simple game, the dealer draws one card for you and him, whoever has the highest card wins, for the purpose of this script I also want to count all ties as dealer wins.
(however on all ties the $loss to the player would be 1/2 of the amount bet for that hand)

I am trying to make a script that:

1. On the input page- Asks how many decks of cards I want to calculate for.
(I want the variable to be 1 through 12 decks of cards)

2. On the input page- Asks how much I want to bet for bets 1 thru 15
(example: I always start my first bet the same, if I lose I bet a different amount on the second bet, if I lose again I bet even different on the 3rd bet, but after I finally win I go back to my first bet level)


SAMPLE:::: I Would Walk To The Betting Table, and on my...

1st hand- I would place a level 1 bet and if I lose,
on the
2nd hand- I would place a level 2 bet and if I lose again,
on the
3nd hand- I would place a level 3 bet and if I lose again,
on the
4nd hand- I would place a level 4 bet and if I finally win,
then on the
5th hand- I would start all over and place a level 1 bet again,
and if I lose, on the
6th hand- I would place a level 2 bet and if I lose again,
on the
7th hand- I would place a level 3 bet and if I finally win,
on the
8th hand- I would start all over and place a level 1 bet again, and if I win again,
on the
9th hand- I would start all over and place a level 1 bet again, and if I win again,
on the
10th hand- I would start all over and place a level 1 bet again

//I imagine when scripting the losses would need to be added to help dictate the betting amount level for the next hand


3. On the input page- Starting Bankroll- Asks how much money I will be starting
the betting with.

4. On the input page- Asks how many hands I want the script to calculate for.
(10 to 1000 hands)

5. On the input page- Has a form button that says "begin"

<--------------------------------------------------------------->
I want the output to be on the output page:

(My Starting Balance
(Hand 1..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 2..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 3..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 4..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 5..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 6..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 7..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 8..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 9..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
(Hand 10..) (My card) (Dealers Card) (Win-or-lose) (New Balance)
//So on and so on depending on how many hands I entered on the input page.

Total hands played:
Wins: (number) and (%)
Losses + Ties: (number) and (%)

<--------------------------------------------------------------->

Any help on this would be appreciated for sure, I would like to do it all myself but I don't know enough about JS to handle it at this time, trust me I have spent some time trying..

Dick Withem...

Dick Withem
02-12-2003, 05:16 PM
:confused: Does anybody in this forum know how to script this? If so please give me an idea how. If it is too hard for the people in this forum please let me know and I will try to find another one..

Thanx

AdamBrill
02-12-2003, 06:37 PM
Do you have a specific question about making the game? or are you just asking someone to make almost the whole script for you? Making a game in javascript takes a lot of work, since javascript really isn't made for that. If you have a specific question, I'd be happy to try to answer you, but I'm not going to make the entire game for you. I have made a paddle wars game with the computer controlling one of the paddles, but it took me about 20 hours or more of programming. I'd be happy to help you, but it takes too long to make an entire game. I'm sure you know what I mean...

Dick Withem
02-12-2003, 06:51 PM
If you look at the info a little closer you will see it is not a game I am trying to make it is more like a results calculator for a game...
Can you give somekind of a short outline on how I might go about scripting this?
Dave told me "slice", but that is all he said and I don't know enough JS to do anything with that.
If you can give me a little something to start with. I can try to go from there...

AdamBrill
02-12-2003, 07:15 PM
Well, I still think it is closer to a game then a results calculator for a game, but.... :)

You will have to make an array that keeps track of all of the cards. To start it would look something like this:

numberOfDecks=3;
cards = new Array("0","0","0","0","0","0","0","0","0","0","0","0","0");
x=0;
do
{
cards[x]=numberOfDecks*4;
x++;
} while(cards[x])

This will make the cards array, set it to have 13 elements(one for each card, Ace through King). Then, it sets it so that it allows each of the cards only to allow how many decks that you make. Then, you will have to make a function that will run every time that it generates a result. It will generate a random number between 0 and 12, 0 being Ace, 1 is 2, 2 is 3, etc. You will have to then check if there are any of those cards to use. If there are, then you subtract one of those card(to subtract one, just do this: cards[random number]--;) and write the results to the page. If there aren't, then you have to get another random number until you get one that there is a card left for. You'll also have to add in a part to check which card is higher. And so on....

I hope this helps. Let me know if you have any more questions...