Please help with my bad code & poorly asked question

This is the place for queries that don't fit in any of the other categories.

Please help with my bad code & poorly asked question

Postby Donovanx » Tue Jul 16, 2013 11:27 am

Ok I'm back with another set of bad code(I have my own bad way of wrighting wich I'm learning of).
So I have 2 class files wich calls wach other my end goal is to have a type of list in a class format(done)
And then have another script called(encounter_randome) to select a npc with all its atributes(I think that's wats it called in a class or instance) and then choose a randome on as an oponent in my game only difucalty I'm having is for the fact that is just chooses one instans(atribute) and I want it to select all then just use that line of the name in a printout and the stats(health, defense)to be uused with a formula and be the batle simulation.
So you now have the picture of wat I want here comes the problems I'm facing.

Code: Select all
from npc_spawn import *
import random

class Randome_():
    def __init__(self, randome_npc):
        self.randome_npc = randome_npc

randome_npc = random.choice([npc_s])
rnpc = (randome_npc)
print (rnpc)


Code: Select all
class npc_spawn():
    def __init__(self, npc, health, defense):
        self.npc = npc
        self.health = health
        self.defense = defense

npc =[npc_spawn("Org", 10, 20),
      npc_spawn("elf", 20, 10),
      npc_spawn("knight", 30, 10)]

#print (npc[0].npc, npc[1].health)
npc_s = (npc[{}].npc, npc[{}].health, npc[{}].defense(1, 1, 1))

With the second piece of code "npc_s" was my idee of a way to get a whole npc but then again its not randome(failed attempt to try and use formating for the job)

And my second problem is getting it so that it will print al three instances(atributes) randomely for any of the npc characters I might add.

If you guys can help me please do!!!
Thanks for the time guys(and don't flame about my bad wrigting. Grammer and so on only helpful replys)
Last edited by Yoriz on Tue Jul 16, 2013 11:52 am, edited 1 time in total.
Reason: Changed the title from 'not sure wat to put as a topic'
Donovanx
 
Posts: 13
Joined: Fri May 10, 2013 1:54 pm

Return to General Coding Help

Who is online

Users browsing this forum: BenGosub, Crimson King, Google [Bot], Yoriz and 6 guests