-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeapon.py
130 lines (115 loc) · 3.56 KB
/
Weapon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 27 00:07:49 2018
@author: X
"""
import random
from Map_ import *
from Player import *
from Item import *
from Assistant import *
class weapon(item):
__typeList = ['Handgun','Small Machine Gun','Rifle','Assult Rifle','Knife']
randNum = len(__typeList)-1
def setType(self):
self.Name = self.__typeList[random.randint(0,self.randNum)]
if self.Name == 'Handgun':
self.type=handGun()
self.shortName = 'hg'
elif self.Name == 'Small Machine Gun':
self.type=smallMachineGun()
self.shortName = 'smg'
elif self.Name == 'Rifle':
self.type=rifle()
self.shortName='rf'
elif self.Name == 'Assult Rifle':
self.type=assultRifle()
self.shortName='ar'
elif self.Name == 'Knife':
self.type=knife()
self.shortName='kn'
pass
class weaponList(itemList):
def generate(self):
yCount = 0
for y in self.map:
xCount = 0
for x in y:
if x==1:
if (random.random()>self.prop):
Weapon = weapon()
Weapon.setType()
self.Dict[(yCount,xCount)]=Weapon
xCount+=1
yCount+=1
pass
class gun(object):
def __init__(self):
self.magazine = 10
self.demage = 10
self.bullet = random.randint(1,self.magazine-5)
self.accuracyRate = 100
#self.distance = None
self.isReloadable = True
pass
def shoot(self):
if self.bullet>0:
self.bullet-=1
return self.demage
else:
print('out of ammo.')
return -1
pass
def reload(self,bulletBag_,bulletNum):
#amount = bulletNum
moreBullet = bulletBag_.popBullet('Universal Bullet',bulletNum)
if moreBullet>-1:
self.bullet+=moreBullet
def gunInfo(self):
info = 'Demage:{value1}|Bullet:{value2}/{value3}'.format(value1 = self.demage,value2 = self.bullet,value3 = self.magazine)
return info
pass
class handGun(gun):
def __init__(self):
self.magazine = 15
self.demage = random.randint(8,15)
self.bullet = random.randint(1,self.magazine-5)
self.accuracyRate = 100
self.isReloadable = True
pass
class smallMachineGun(gun):
def __init__(self):
self.magazine = 30
self.demage = random.randint(5,10)
self.bullet = random.randint(1,self.magazine-15)
self.accuracyRate = 100
self.isReloadable = True
pass
class rifle(gun):
def __init__(self):
self.magazine = 6
self.demage = random.randint(25,40)
self.bullet = random.randint(1,self.magazine-3)
self.accuracyRate = 100
self.isReloadable = True
pass
class assultRifle(gun):
def __init__(self):
self.magazine = 25
self.demage = random.randint(15,30)
self.bullet = random.randint(1,self.magazine-15)
self.accuracyRate = 100
self.isReloadable = True
pass
class knife(gun):
def __init__(self):
self.magazine = 30
self.demage = random.randint(8,15)
self.bullet = self.magazine
self.accuracyRate = 100
self.isReloadable = False
def gunInfo(self):
info = 'Demage:{value1}|Durability:{value2}/{value3}'.format(value1 = self.demage,value2 = self.bullet,value3 = self.magazine)
return info
pass
###################