Murtan 317 Practically a Master Poster

Will the users of your application be connecting to your SQL server or is the intent for them to connect to their own server?

The following presumes they will be connecting to your server:

Hard coding the connection string makes it a little harder to find, but unless you're encrypting it somehow, it would show up if the application file was scanned for text.

Some form of light encryption along with hard coding makes the connection information non-trivial to find, but it would be even more secure if the connection the program used was NOT an administrator connection for the server.

There might be other connection types available that might not require the program to have a user name and password. (I'm thinking windows authentication, but that might not always be available or might not be a viable option.)

Murtan 317 Practically a Master Poster

Maybe you should look at the python bit-wise operators in the Python Docs

Murtan 317 Practically a Master Poster

Were you using the formula from page 8 of the pdf?

Shouldn't it be more like this?

return (0.0 + c - min(a, b)) / max(a, b)

I could be wrong, it wouldn't be the first time (grin).

Murtan 317 Practically a Master Poster

Your posted code did have [code]

[/code] tags, but if you use the language specific tags [code=python] [/code] for example, you get line numbers and syntax highlighting as well. The syntax highlighting makes the code easier to read and the line numbers give you a point of reference if you need to talk about just part of the code.

Murtan 317 Practically a Master Poster

Line 26 should be:

if ((convert=fopen("convert.txt","r"))==NULL)

I have a couple of points and several questions about the encryption loop:

while(c!=EOF)
	{
		ch=ch+c;
		ch=ch/2;
		c+=ch;

		fputc(c,encrypt);
		c=fgetc(inputf);

	c=fgetc(convert);
	cout<<"\nThe file is encrypted";

	}

The while c != EOF should work, but you should pre-initialize c to something.

The cout with the message should be after the loop (which should iterate for each character).

What does this code do?

ch = ch + c;
ch = ch / 2;
c += ch;

ch didn't have any specific value before we started and we never use it again. The first time through the loop, c doesn't have a specific value either.

If you initialized c with a c = fgetc(inputf); before the while loop, it might make more sense, but it still ignores the contents from file 1.

I think your loop was terminating early, because the c = fgetc(convert); was failing, because you never got convert open.

Murtan 317 Practically a Master Poster

you showed us the content of the file...

a =z
b=y
c=x
d=w
e=v
f=u
g=t
h=s
i=r
j=q
k=p
l=o
m=n
n=m
o=l

So I'm presuming that you're will need to read each line of the file, parse it to find what's on the left and the right of the '=' and setup the 'encryption' to use that mapping.

I'm not willing to go much farther without seeing more of your own effort.

Murtan 317 Practically a Master Poster

First, the directory structure shown by walk doesn't quite appear to match what you said the structure would be.

For example, the directories under Library appear to be prefixed with a number (as in 1_Vrijstaand).

For another example, the files under the individual directories don't show the 1_simple.max, 1_detailed.max, 1.csv structure you indicated, but just 1.max and 1.csv

Are the 1_simple.max and 1_detailed.max going to exist?

Will it always be 'simple' and 'detailed' or might there be other words between "1_" and ".max" that you have to collect as well.

I personally, try not to change directories once my application is started. I'm not against you doing it if it makes sense, but as you passed an absolute directory to os.walk I don't suspect it was required.

I'm going to recommend that you create some classes to hold more of your data and then you can fill the classes as you either walk the libaray or use an alternative iteration.

I'm thinking an instance of a class for each subdirectory under Library. Then inside that class intance, you could create an instance of another class for each csv file you find in the subdirectory. That class would also store the names of all of max files that match the csv name. (You will need to be careful to make sure that you don't put '10_simple.max' under the class for '1.csv'.) Note that this is not quite the structure that you proposed, but it …

Murtan 317 Practically a Master Poster

So the first file defines the 'encryption'
The second file contains the 'message' to be encrypted.
The third file you are supposed to generate as the encrypted message?

If so, you will need to open and parse the first file, using the data you find to develop the translation. I would interpret your sample file one to mean that when you see the letter 'a' in the message, you should put a 'z' in the encrypted message. But don't hard-code this specific mapping, you need to read the first file and interpret each of the lines.

Then you open the second file for input, the third file for output and start encrypting the input message, writing the output to the third file.

Show us what you understand (to show that you're trying, we won't help if you aren't putting in an effort) and identify specific issues like: "I'm expecting the program to do ___, but it is doing ___" or "The program won't compile, I'm seeing error '--insert exact compiler error here--' on line ___." and include your source.

When posting c++ code, please use c++ code tags
[code=c++] // Your code here

[/code]

Murtan 317 Practically a Master Poster

I was working on revamping the code...most of it would need changes to work with the classes.

Murtan 317 Practically a Master Poster

Ok, I'm going to post this...I've started it several times and then you post a significant rewrite of your code and to help you I have to toss this stuff out.

You can use the idea and expand on it, or ignore it, it's up to you, but I think that this would make your code easier to work on and more maintainable.

I think you should be doing more with classes, but I surely did not mean for you to turn your whole game into one large class. You are also using class variables in many instances where they are not needed. If you only use a variable within a single function, it does not need to be a member of a class.

Here's a start at classes to support stores and items:

class NQShopItem(object):
    """
    This class holds the information common to all shop items
    """
    def __init__(self, name, price, reqLevel, reqRank):
        self.name = name
        self.price = price
        self.reqLevel = reqLevel
        self.reqRank = reqRank
    
    def shopline(self, idx):
        return "   %2d - %-32s $%5d" % (idx, self.name, self.price)
    
class NQWeapon(NQShopItem):
    """ 
    This is a class that represents weapons in NorbertQuest
    """
    def __init__(self, name, price, reqLevel, reqRank, damage):
        #NQShopItem.__init__(self, name, price, reqLevel, reqRank)
        super(NQWeapon, self).__init__(name, price, reqLevel, reqRank)
        self.damage = damage

NQWeaponList = [
    #         Name              Cost Lvl rank  Dam
    NQWeapon("Hands",              0,  1,   0,   0),
    NQWeapon("Steel Knuckles",    50,  1,   0,  35),
    NQWeapon("Knife",             75,  2,   0,  55),
    NQWeapon("Sword",            300,  3,   0,  90),
    NQWeapon("Gun",              800,  4,   0, …
Murtan 317 Practically a Master Poster

The lines:

self.weapons[1:"Steel Knuckles",2:"Knife",3:"Sword",4:"Gun",5:"Rocket Launcher"]
self.armors[1:"Leather Jacket",2:"Padded Sweater",3:"Iron Arm-shield",4:"Bullet-Proof Jacket",5:"Bomber Squad Armor Plated Suit"]

don't work for me. It looks like you intended to create a list, but instead you're trying to use a really strange index.

I think you intended one of the following:

# dictionary implementation
# best matches the data as you provide it
self.weapons = {1:"Steel Knuckles",2:"Knife",3:"Sword",4:"Gun",5:"Rocket Launcher"}
self.armors = {1:"Leather Jacket",2:"Padded Sweater",3:"Iron Arm-shield",4:"Bullet-Proof Jacket",5:"Bomber Squad Armor Plated Suit"}

# list implementation
# is this more what you really want?
self.weapons = ["Hands", "Steel Knuckles", "Knife", "Sword", "Gun", "Rocket Launcher"]
self.armors = ["Skin", "Leather Jacket", "Padded Sweater", "Iron Arm-shield", "Bullet-Proof Jacket", "Bomber Squad Armor Plated Suit"]

# in either case, I would tend to format the code like this:
# because I think it is more readable
self.weapons = [
    "Hands",
    "Steel Knuckles",
    "Knife",
    "Sword",
    "Gun",
    "Rocket Launcher",
    ]
Murtan 317 Practically a Master Poster

Line 242 (line 2 in the fragment):

elif self.deposit <= self.money:
    self.bankbalance = self.money - self.deposit
    self.money = self.money - self.deposit
    print"Your new bank Balance is",self.bankbalance,"dollars. Thank you."
    self.mode = "restart"

When depositing to the bank, we need to increase the bank balance and decrease the gold:

self.bankbalance = self.bankbalance + self.deposit
    self.money = self.money - self.deposit

You have a similar problem in withdraw:

elif self.withdraw <= self.bankbalance:
    self.money = self.bankbalance - self.withdraw
    self.bankbalance = self.bankbalance - self.withdraw
    print"Your new bank Balance is",self.bankbalance,"dollars. Thank you."
    self.mode = "restart"

When withdrawing, we need to increase our money and decrease the bank balance:

self.money = self.money + self.withdraw
    self.bankbalance = self.bankbalance - self.withdraw
Murtan 317 Practically a Master Poster

If you're having a problem with part of the code, please be specific as to what the problem is. What did you see? What did you expect to see?

If it is a compile problem, include the full text of the compiler error if possible.

I saw something interesting in your new banking code, you ask for the amount to deposit/withdraw using raw_input. This alone is not a problem but it does mean that the amount is a string and not a number. You will need to convert it to a number before you attempt to compare against the balance or the cash-on-hand.

Murtan 317 Practically a Master Poster

const is a 'promise' not to change.

If you have member-functions that do not change your class (and never should) you can declare them const.

const member-functions are declared like this:

int getValue() const;

The primary purpose for const member-functions is that they are the only member-functions you can call for a const reference to that class.

Functions that need to be able to look at a class but do not need to change it should declare the parameter as a const reference.

class Sample;
int myfunc(Sample const & data)
{
//...
}

Inside myfunc (above) the only member-functions of data that can be called are the const member-functions.

Murtan 317 Practically a Master Poster

@VernonDozier
You're right (again), I missed the fact that they would all be 3's to start.

Not that it is an excuse, but my convention for TTT win checks is to check for matches against the last player to move so it wouldn't have seen the 'empty' locations.

@jesse_johnson2
Why do you maintain both g_table and mytable?

I know g_table is to display and mytable is to check for wins, but couldn't you just as easily check for wins against g_table?

Murtan 317 Practically a Master Poster

It would appear that inside move, placement is actually getting set to true when the game is 'won' but nothing is looking at placement to stop the game. The only stop case is when the board is full.

Murtan 317 Practically a Master Poster

Oh, and please:

When posting c++ code, please use c++ code tags
[code=c++] // Your code here

[/code]

Murtan 317 Practically a Master Poster

Actually, it should never get to that print line...it returns from inside all over the function. (Though I'm not sure that the returns in all of the test are required.)

Is the board required to be in an int tttb[3][3] or could we store it in an int tttb[9] and just display it in a 3 x 3 grid?

There is a lot of repeated code, creating a few more functions would clean this up a lot. The function move() is especially large.

Murtan 317 Practically a Master Poster

Ok, just to make sure I understand, you're running on computer A and can telnet to computer B. You want computer B to telnet to computer C?

Why not telnet from computer A to computer C directly?

If the above A -> B -> C scenario is what you're trying to do, you will need to 'convince' computer B to telnet to computer C. I suspect that you will either have to run the 'standard' telnet application on computer B, or run another program on computer B that achieves the same goal. If it was necessary, you could probably even 'create' a python file on computer B and run it to establish the connection to computer C. The options available to you could be limited by the access granted to your connection to computer B.

Murtan 317 Practically a Master Poster

The saved games should not change the code, but if you posted the file with the saved game in it, we should be able to save it and have the game load it like it was our saved game.

Murtan 317 Practically a Master Poster

I meant the second code fragment in post 32 where I posted you an entire file full of working code. The code isn't a fully complete version, but it would in fact compile and run.

I last posted about saving back in post # 14

The 'save' feature is something you'll have to work on as well. First step is to decide what it is that you want to save. We don't have one yet, but does the player have a name? They have gold and a weapon, is that what we save? Do we want to keep some form of battle statistics and save them?

The basic file concepts (from your 'how do I save' thread) are how you get data into and out of the file. How your application interfaces to the files is up to you, but I recommend something like this:

* Set variables to the default value
* Check for the save file
* If the save file exists, update the variables from the file


To get the save file created, the application either needs to do saves from time to time (oh, like whenever they complete a battle or shop at the store) or just save when the program exits.

Murtan 317 Practically a Master Poster

What if we changed decode?

def decode(loc):
## Funktion för att översätta user input från A4 till listindex.
## den skall returnera -1 om platsen inte är giltig.
    letter = loc[0].upper()
    numchar = loc[1]
    if numchar.isspace():
        numchar = loc[2]
    number = int(numchar)
    # the rest of decode still goes here...

or we could try to use the length as a clue:

def decode(loc):
## Funktion för att översätta user input från A4 till listindex.
## den skall returnera -1 om platsen inte är giltig.
    if len(loc) == 2:
        letter = loc[0].upper()
        number = int(loc[1])
    elif len(loc) == 3:
        letter = loc[0].upper()
        number = int(loc[2])
    # the rest of decode still goes here...

Python has a feature where if we say loc[-1] we get the last character of loc. If we use that:

def decode(loc):
## Funktion för att översätta user input från A4 till listindex.
## den skall returnera -1 om platsen inte är giltig.
    letter = loc[0].upper()
    number = int(loc[-1])
    # the rest of decode still goes here...
Murtan 317 Practically a Master Poster

Line 96 should be:

self.e = self.eAttack()

The self.tnls on line 114 does not belong. It was moved to line 14.


(Why did you only copy part of the source when I went to the trouble to fix it all so it would run?)

You now have the 'main loop' of the program as part of the EnemyHP() function and that is NOT where it belongs.

If there is something about a suggestion you don't understand, ask about it, don't ignore it.

Murtan 317 Practically a Master Poster

Lines 109-112 fill the list liobj with a Ruta created from the words in valdaord. This should only happen once.

When you call drawBoard, you should only pass liobj: drawBoard(liobj) drawBoard should NOT attempt to fill the wlist, it is already full. The corrected drawBoard is:

def drawBoard(wlist):
    print '      1       2       3       4       5       6'
    for row in range(6):
        print chr(65 + row),
        for col in range(6):
            print "%7s" % wlist[row * 6 + col],
        print

Your current decode function does not validate the number part of the coordinate. (It would accept A9 for example.) It also has a problem with coordinates that do not have a number as the second digit, 5C for example (which is invalid, but shouldn't cause your program to exit).

In my version, doFlip called decode, I didn't call decode from the main, but either implementation works. One of the locations (either doFlip or main) needs to confirm that the card they select is face down. It would be bad form to let them pick the same card twice.

Murtan 317 Practically a Master Poster

I'm not sure what prompted you to turn the whole thing into a class, but I'll go with it if that's what you want to do.

It was said earlier, but ALL of the functions in the class need to have self as the first parameter:

def Shop(self):
    def eAttack(self):
    def HP(self):
    def nAttack(self):
    def LVL(self):
    def EnemyHP(self):

And you were NOT supposed to indent them all under __init__(self)

Ok I tried to do only the minimum required to get this to run, but I did move a couple of lines around and I made a Battle(self) function like the Shop(self) function.

import random
class NorbertQuest(object):

    def __init__(self):
        self.w = 0
        self.level = 1
        self.m = random.randrange(50)+1+self.level*5
        self.cost = 0
        self.xp = 0
        self.health = 150
        self.ehealth = 100
        self.money = 0
        self.tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900]

    def Shop(self):
        self.weapon1 = "Steel Knuckles"
        self.weapon2 = "Knife"
        self.weapon3 = "Sword"
        self.weapon4 = "Gun"
        self.weapon5 = "Rocket Launcher"
        print \
         """
         What'll it be?
         1 - Steel Knuckles 20$
         2 - Knife 30$
         3 - Sword 100$
         4 - Gun 300$
         5 - Rocket Launcher 1000$
         Type exit to quit.
         """
        self.z = input("Which weapon do you want?")
        if self.z == 1:
            self.cost = 20
            if self.money >= self.cost:
                print"You have bought",self.weapon1
                self.money = self.money - self.cost
                self.w = 1
                self.mode = "restart"
            elif self.money < self.cost:
                print"You don't have enough gold to buy this."
                raw_input("Press [enter] to exit.")
                self.mode = …
Murtan 317 Practically a Master Poster

The 'funny' part is, that you don't really have to split the loc at all and the decode prototype (with only one loc) was how I used it. All decode does is translate from 'a1' to 0, 'a2' to 1, 'a3' to 2, 'b1' to 6, ...

If there was anything wrong with the loc, it would complain and return -1.

My decode used if not loc[0].upper() in rowltr where rowltr was "ABCDEF" to decide to complain about an invalid row letter. I used a similar test against the string colnum ("123456") for validating the column. Once it was determined that the loc[0] and loc[1] were valid, I used rowltr.index(loc[0].upper()) to get the row index (0-5) and colnum.index(loc[1]) to get the column index (0-5) and then calculated the return value as row * 6 + col.

Your set of 'ifs' would have worked, except that the number in your examples is still a string, but you try to use it in math. (Didn't you try to test your function?)

my doFlip(wlist, loc) would call idx = decode(loc) , if the idx was < 0 then loc was invalid. Otherwise, it would look to see if the card at idx was already face up. If it was already face up, it would complain and return False. If it was face down, it would turn it face up and return True.

my doCompare(wlist, loc1, loc2) would call decode() twice, once for each loc. It didn't really do …

Murtan 317 Practically a Master Poster

Just because you 'could' do most of it in main doesn't mean you 'should'.

Start simple, write and test a simple function, make sure to give it both valid and invalid inputs. Make sure that it handles everything that it might expect to see.

For example, when I was testing the decode function, I gave it several valid values: 'A1', 'B5', 'f2', 'c4' but I gave it invalid values as well: 'c0', 'g3', 'a 4', '3c', 'd34', 'bug', 'dd'. I used my decode to help validate the user input. My version of the decode function actually displays the error messages using print. (This part will need to be reworked a little if I decide to make a GUI for the progam, but so will a lot of other code.)

Murtan 317 Practically a Master Poster

I would like to better understand your vision for the project.

What are the project's goals?

When it is 'done' what do you see being able to do with it?

Who would be the intended users?

Why would they choose this alternative over the others?

Murtan 317 Practically a Master Poster

Ok, so you appear to have some code there already. I don't see any notes there about what you want to do that needs more developers.

Where are you wanting to take the project that you would like to have help with?

(If I offered to help, what would you like me to do?)

Murtan 317 Practically a Master Poster

Just as a side note, you could make the game a lot easier (potentially faster too) if you would let the user select things by number.

For example when selecting "battle" "shop" or "exit" if the menu was:

Available options:
    1 - Battle
    2 - Shop
    3 - Exit
What would you like to do?

The user could enter '1', '2' or '3' instead of having to type out the whole word.

The same could be applied to the battle sequence.

But even better, might be some way to more automate the battle...something like 'auto-attack' that would keep attacking until the monster was dead or you died. (Maybe you could work out a way for the player to make some input into the battle while it was in-progress?)

In my sample play, I don't believe I have ever been killed by a monster. Especially not after I upgraded my weapons.

Oh...another usability item...when you open the shop, it would be nice to tell them which weapon they're using and how much money they have so they would know what they could afford and which weapons would be an upgrade to the weapon they have.

Murtan 317 Practically a Master Poster

When posting python code, please use python code tags
[code=python] # Your code here

[/code]

You didn't get everything that was supposed to be in main indented.

Here's the outline of how my code is organized...you don't have to match all of my code, this is just how I have it implemented.

import random

wordsize = 7

def spacepad( inword, padlen):
## This is the function that takes the input word (inword)
## and a size (padlen) and 'centers' the word by adding
## spaces around it until it is at least padlen characters long

class Ruta:
## This is the class that holds the word and whether or not
## the card is face up.

def drawBoard(wlist):
## This function draws the board (from the list of Ruta objects in wlist)

def decode(loc):
## I wrote this function to translate from 'A2' or 'B4' to the array index
## it returns -1 if the location is not valid

def doflip(wlist, loc):
## This function calls decode on the loc and then turns the card face up
## It will return false if the card is already face up, or if the location
## specified is invalid.

def docompare(wlist, loc1, loc2):
## This function compares the two cards (which must be face up)
## If the cards match it returns True
## If the cards do not match it turns the cards face down
## and returns False

# this is my entire main function
def …
Murtan 317 Practically a Master Poster

PS- your player attack function:

def nAttack():
    attack = random.randrange(10)+level*5
    return attack
    if w == 1:
        attack = random.randrange(10)+20+level*5
    elif w == 2:
        attack = random.randrange(10)+35+level*5
    elif w == 3:
        attack = random.randrange(10)+55+level*5
    elif w == 4:
        attack = random.randrange(10)+80+level*5
    elif w == 5:
        attack = random.randrange(10)+110+level*5

Is still not using any new weapon calculations. (The return on line 3 causes the remaining code to be ignored.) The return should be at the end.

def nAttack():
    attack = random.randrange(10)+level*5
    if w == 1:
        attack = random.randrange(10)+20+level*5
    elif w == 2:
        attack = random.randrange(10)+35+level*5
    elif w == 3:
        attack = random.randrange(10)+55+level*5
    elif w == 4:
        attack = random.randrange(10)+80+level*5
    elif w == 5:
        attack = random.randrange(10)+110+level*5
    return attack
Murtan 317 Practically a Master Poster

I think nav33n (who re-posted your code) was trying to encourage you to use code tags.

Please use code tags when posting code. For more information, click here.

When posting php code, please use php code tags
[code=php] // Your code here

[/code]

Murtan 317 Practically a Master Poster

you didn't want to keep indenting each new 'if level' test

They should all be at the same indent level, like if level == 1 and if level == 2 are.

(I had typed the following and thought I had posted it, but apparently not...here it is anyway)

Have you ever heard of an array or a list?

If you had a data structure that contained (or was indexed by) the level and the 'tnl' value, the LVL() function could have been implemented with a loop instead of 10 levels or if's with almost identical code that follows each of them. What do you plan to do in the 'official' version when there are more than 10 levels?

I tend to think about XP as always increasing. In my world, XP from 0 to 99 is level 1. XP from 100 to 349 would be level 2, XP 350-799 is level 3...etc.

So if I was at 97 XP and killed a monster worth 20 XP, I could be at 117 XP in level 2 instead of level 2 with zero XP. (Granted that even in your model, instead of setting XP back to zero, you just subtracted the old tnl value you would get the same result.

Murtan 317 Practically a Master Poster

No the problem is with python...you can't run python code without having python installed (or using the large python dll that has all of the python stuff in it.) The python code expects that all to be there.

If you want to reduce the size of what you're shipping, you need to use a language that is better able to be selective about what it has to have to run (like C).

Murtan 317 Practically a Master Poster

Where is the declaration of com_num in relation to the order function? com_num needs to be visible to any compile target that can see order.

What specifically is the compiler error?

Which is the line that generates the compiler error?

Murtan 317 Practically a Master Poster

I think the problem with the 'both' option is that when you select 'both' on the form, gender is set to '' and not to 'both'.

Murtan 317 Practically a Master Poster

I called that second part from the Ruta __init__:

wordsize = 7

    def __init__(self, ord ):
        self.ord = spacepad(ord, wordsize)
        self.hidden = True

I actually declared a main function

def main():
    infile = open("memo.txt", "r")
    words = []
    valdaord = []
    words = infile.readlines()
    infile.close()
    random.shuffle(words)

Inside main, the game loop starts like this:

nmatch = 0    
    nguess = 0
    while nmatch < 18:
        drawBoard(liobj)

drawBoard displays all of the words in the grid. Note that I pass it the liobj list with all of the Ruta in it. The liobj list is local to my main so I have to pass it to the functions that help.

My input validation routines allow the user to select a card, but before they accept the card, they confirm that it is hidden. They also test to make sure the selection is in range and properly formatted. (I have the user select a card like 'B3' or 'C4')

I ask for the first card (validate it) flip it and drawBoard again.
I ask for second card (validate it) flip it and drawBoard again.
Then I compare the first card to the second card, if the cards match, I increment nmatch. If they don't match I flip both cards back.

Unless the game is over, the loop in main goes back and draws the board again.

Murtan 317 Practically a Master Poster

You can put the health reset in the main loop, just before the battle loop starts. You'll reset it more than you need to, but everyone will be full health when the battle starts.

while True:
    print \
          """
          Welcome to NorbertQuest!
          Type:
          - [battle] to hunt monsters
          - [shop] to buy weapons
          - [exit] to quit the game.
          """
    mode = raw_input("What do you want to do?: ")
    if mode == "shop":
        Shop()

    # reset health here

    while mode == "battle":
        fight = random.randrange(10)+1

In order to get pictures on the screen, you're going to have to change the program a lot. You need to use one of the python gui models to run your application and they run a lot differently than you have been so far. (I saw your other gui thread. I have used both wxPython and tkInter to fairly good success, you'll have to pick one.)

The 'save' feature is something you'll have to work on as well. First step is to decide what it is that you want to save. We don't have one yet, but does the player have a name? They have gold and a weapon, is that what we save? Do we want to keep some form of battle statistics and save them?

The basic file concepts (from your 'how do I save' thread) are how you get data into and out of the file. How your application interfaces to the files is up to you, but I …

Murtan 317 Practically a Master Poster

I just pulled the object out...

<div class="clear">
      <!-- begin embedded WindowsMedia file... -->
      <table border='0' cellpadding='0' align="center">

      <tr>
        <td>
	-Player Goes Here-
      </td></tr>
      <!-- ...end embedded WindowsMedia file -->
      </table>
</div>

And it worked when I had Firefox load the local file, I don't have a convenient webserver that I could post it to for testing with an internet link.

Murtan 317 Practically a Master Poster

The 'link to problems' you give is to the w3.org validator for the site.

The first error listed is Line 24, Column 21: document type does not allow element "div" here; assuming missing "li" start-tag. The relevant section of your html is here:

<ul>
				<li></li>
					<div id="texto1">****** | home | about | contact | ******</div>
				</ul>

The error says that the div should be 'inside' the li...like this:

<ul>
				<li>
					<div id="texto1">****** | home | about | contact | ******</div>
				</li>
			  </ul>

The indentation and line breaks are not required, but your document seems to be using them. Line 33, Column 29: document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag. is complaining about the <div> inside the <p>

<p>Up to <div id="texto3">250</div> listeners! <div id="texto2">(NEW)</div></p>

I'm not sure what your intent was, but because the div is inside the p, you get the line break. Would a <span> work?

The error list also refers you to an article about embedding flash movies here

Though this doesn't seem to apply directly in this application.

The code to embed the player is at the end of the html. You have the player embedded in a table inside of a div. The table specifies align="center" which appears to center the control in IE, but is not centering it in Firefox. I'm not sure what the problem is, when I removed …

Murtan 317 Practically a Master Poster

Your goals are still VERY vague, but the bottom line is that for most peer-to-peer chat programs, you will open a socket between the two computers. Whether they hold the socket open (likely) or open and close it is an implementation detail.

To get the socket initially established, one of the peers needs to be 'listening' for a connection on a port. The other peer must then attempt to open the socket where the first peer is listening. (You could potentially do this on one computer for testing.) Once the socket is established, the contents of the data stream are up to your application. The first parts sent across the link would commonly be an exchange of user identification and/or authentication.

Murtan 317 Practically a Master Poster

If you have all of the indenting right, I think that should be ok. If not, post the code along with the compiler error and we'll figure it out.

Murtan 317 Practically a Master Poster

Try this for the display:

print
    #      # ####### ####### ####### ####### ####### #######
    print '     1       2       3       4       5       6'
    for row in range(6):
        print chr(65 + row),
        for col in range(6):
            print "%7s" % liobj[row * 6 + col],
        print

In my sample code, I expanded the space for a word to 7 letters (my list had a couple of 6 letter words on it.)

I modified Ruta to use 7 dashes instead of 3 and I also modified it to 'center' the word in 7 spaces so I could skip the forced left or forced right alignment.

It was a bit brute force, but I used:

def spacepad( inword, padlen):
    if len(inword) < padlen:
        nspace = padlen - len(inword)
        nlead = nspace / 2
        ntail = nspace - nlead
        return ' ' * nlead + inword + ' ' * ntail
    return inword
Murtan 317 Practically a Master Poster

The problem in the store is the mixing of assignment and test operators. You must use == for comparison and = for assignment.

You have:

if z == 1:
        cost == 20
        if money >= cost:
            print"You have bought",weapon1
            money = money - cost
            w == 1
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"

It should be:

if z == 1:
        cost = 20
        if money >= cost:
            print"You have bought",weapon1
            money = money - cost
            w = 1
            mode = "restart"
        elif money < cost:
            print"You don't have enough gold to buy this."
            raw_input("Press [enter] to exit.")
            mode = "restart"

Try that and see if it helps.

Murtan 317 Practically a Master Poster

Have you done anything with your program in the last couple of days?

Did you like any of the suggestions?

Normally, we like to give you advice and don't like to write your code for you. The help you receive tends to vary directly with the amount of effort you appear to be putting in. We (ok I) feel that putting in effort to contribute to the solution (even if you got the idea from someone else) helps you to learn more from the process.

If you like an idea, but are having trouble implementing it, show us your work (-- this shows your effort --) and we will help you correct what isn't working.

If you've been working on the code and making changes, please post the updated code. If you're having problems with the updated code, describe what it is doing and what you wanted it to be doing and we'll make suggestions on how to get the two closer together.

Murtan 317 Practically a Master Poster

I would reset the player and monster health at the start of the battle.

The weapons would make a good class, the weapon has a name, a cost and an amount of damage. Then you could make a list of weapons that could be iterated for display at the shop. When the player buys a weapon, you could update their 'current' weapon and then use the 'current' weapon when calculating damage during the battle.

The following is some sample code of how the shop might work after you create the weapon class and a list of them. The sample code does not attempt to format the list in a 'pretty' form or to validate the user input, both would be beneficial updates.

for idx in range(len(weaponlist)):
    print idx + 1, weaponlist[idx].description, weaponlist[idx].cost
z = input("Which weapon do you want?")
if money > weaponlist[z].cost:
    playerweapon = weaponlist[z]
    print "You have bought", playerweapon.description
else:
    print "You can't afford the", weaponlist[z].description

The functions that display the health (of the player and the enemy) also calculate the damage applied and as such are poorly named. (The function name does not reflect what it does.) I would tend to separate them into a couple of functions, one to display the health and another to calculate the damage for an attack and apply it.

In the current program it is possible that the player might not have enough money to even buy the lowest weapon. If they can't buy a weapon, how …

Murtan 317 Practically a Master Poster

Optionally, unless the requirements specifically require that you use a 6 by 6 matrix internally, the program could continue to store the grid in a single list. The internal program structure of your data does not need to be the same as the external representation. Use the internal structure that makes the most sense and makes the implementation the easiest.

You just have to be able to display it as a grid and reference the list like it was a grid.

For the list, elements 0-5 would be row 1, 6-11 row 2, etc.

So if row is 0-5 and col is 0-5 the index would be (row * 5 + col) .

If row is 1-6 and col is 1-6 adapt by subtracting one when doing the calculation. ((row - 1) * 5 + (col - 1)) I would be tempted to implement a 'board' or 'table' class that supported displaying the matrix to the player and allow the rest of the program to reference elements in the list like it was a 6 x 6 matrix. The class could optionally also support using letters as the row index if that would help.

Murtan 317 Practically a Master Poster

In the ZIP file, student.h still contains: SinglyLinkedList<CourseInfo> courseList; so the student does NOT contain a linkedStack.

If you want it to contain a linkedStack, you have to tell the compiler by changing the line.

Murtan 317 Practically a Master Poster

Please when posting to these forums, wrap your code in code tags (like daviddoria did above).

Use either:

[code] ... [/code]
or
[code=c++]... [/code]

The second form provides for syntax highlighting and line numbers.