Initial commit
This commit is contained in:
33
BookCraigRichardson/classes/birdClass.py
Normal file
33
BookCraigRichardson/classes/birdClass.py
Normal file
@@ -0,0 +1,33 @@
|
||||
class Bird(object):
|
||||
def __init__(self, name, wingspan):
|
||||
self.name = name
|
||||
self.wingspan = wingspan
|
||||
def birdcall(self):
|
||||
print("чик-чирик")
|
||||
def fly(self):
|
||||
print("хлоп-хлоп")
|
||||
class Penguin(Bird):
|
||||
def swim(self):
|
||||
print("умеет плавать")
|
||||
def birdcall(self):
|
||||
print("квак")
|
||||
def fly(self):
|
||||
print("пингвины не летают :(")
|
||||
class Parrot(Bird):
|
||||
def __init__(self, name, wingspan, color):
|
||||
self.name = name
|
||||
self.wingspan = wingspan
|
||||
self.color = color
|
||||
|
||||
gardenBird = Bird("Geoffrey", 12)
|
||||
gardenBird.birdcall()
|
||||
gardenBird.fly()
|
||||
sarahThePenguin = Penguin("Sarah", 10)
|
||||
sarahThePenguin.swim()
|
||||
sarahThePenguin.fly()
|
||||
sarahThePenguin.birdcall()
|
||||
freddieTheParrot = Parrot("Freddie", 12, "синий")
|
||||
|
||||
print(freddieTheParrot.color)
|
||||
freddieTheParrot.fly()
|
||||
freddieTheParrot.birdcall()
|
||||
34
BookCraigRichardson/classes/catClass.py
Normal file
34
BookCraigRichardson/classes/catClass.py
Normal file
@@ -0,0 +1,34 @@
|
||||
class Cat(object):
|
||||
|
||||
owner = "Андрей"
|
||||
|
||||
def __init__(self, name, weight):
|
||||
self.name = name
|
||||
self.weight = weight
|
||||
|
||||
def getWeightInGrams(self):
|
||||
return self.weight * 1000
|
||||
|
||||
def eat(self, food):
|
||||
self.weight = self.weight + 0.05
|
||||
print(self.name + " ест " + food)
|
||||
|
||||
def eatAndSleep(self, food):
|
||||
self.eat(food)
|
||||
print(self.name + " теперь спит...")
|
||||
|
||||
myCat = Cat("Барсик", 4.5)
|
||||
mySecondCat = Cat("Мурка", 3.9)
|
||||
mySecondCat.owner = "Бабу:)"
|
||||
print("имя кота: " + str(myCat.name))
|
||||
print("имя кошки: " + str(mySecondCat.name))
|
||||
print("вес кота до еды: " + str(myCat.weight))
|
||||
print("вес кота до еды в граммах: " + str(myCat.getWeightInGrams()))
|
||||
mySecondCat.eat("торт")
|
||||
myCat.eatAndSleep("рыбу")
|
||||
|
||||
print("вес кота после еды: " + str(myCat.weight))
|
||||
print("вес котапосле еды в граммах: " + str(myCat.getWeightInGrams()))
|
||||
|
||||
print(myCat.owner)
|
||||
print(mySecondCat.owner)
|
||||
58
BookCraigRichardson/classes/ghostCastle.py
Normal file
58
BookCraigRichardson/classes/ghostCastle.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from mcpi.minecraft import Minecraft
|
||||
mc = Minecraft.create()
|
||||
import time
|
||||
import random
|
||||
|
||||
buildingName = input("Как назовем замок? (только англ. буквами) ")
|
||||
kolVo = int(input("Сколько раз появиться замок? "))
|
||||
|
||||
class NamedBuilding(object):
|
||||
def __init__(self, x, y, z, width, height, depth, name):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.depth = depth
|
||||
self.name = name
|
||||
def build(self):
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x + self.width, self.y + self.height, self.z + self.depth, 4)
|
||||
mc.setBlocks(self.x + 1, self.y + 1, self.z + 1, self.x + self.width - 1, self.y + self.height - 1, self.z + self.depth - 1, 0)
|
||||
|
||||
def buildDoor(self):
|
||||
mc.setBlocks(self.x + (self.width / 2), self.y + 1, self.z, self.x + (self.width / 2), self.y + 2, self.z, 0)
|
||||
|
||||
def buildWindows(self):
|
||||
mc.setBlock(self.x + (self.width / 4 * 3), self.y + 2, self.z, 0)
|
||||
mc.setBlock(self.x + (self.width / 4), self.y + 2, self.z, 0)
|
||||
|
||||
def clear(self):
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x + self.width, self.y + self.height, self.z + self.depth, 0)
|
||||
|
||||
def getInfo(self):
|
||||
return self.name + " imeet koordinati " + str(self.x) + ", " + str(self.y) + ", " + str(self.z)
|
||||
|
||||
pos = mc.player.getTilePos()
|
||||
x, y, z = pos.x, pos.y, pos.z
|
||||
|
||||
ghostBuilding = NamedBuilding(x, y, z, 10, 16, 16, buildingName)
|
||||
|
||||
def buildAndClear():
|
||||
|
||||
ghostBuilding.build()
|
||||
ghostBuilding.buildDoor()
|
||||
ghostBuilding.buildWindows()
|
||||
|
||||
mc.postToChat(ghostBuilding.getInfo())
|
||||
|
||||
time.sleep(15)
|
||||
|
||||
ghostBuilding.clear()
|
||||
|
||||
ghostBuilding.x = random.randint(ghostBuilding.x - 50, ghostBuilding.x + 50)
|
||||
ghostBuilding.z = random.randint(ghostBuilding.z - 50, ghostBuilding.z + 50)
|
||||
ghostBuilding.y = mc.getHeight(ghostBuilding.x, ghostBuilding.z)
|
||||
|
||||
|
||||
for i in range(kolVo):
|
||||
buildAndClear()
|
||||
104
BookCraigRichardson/classes/ghostHotel.py
Normal file
104
BookCraigRichardson/classes/ghostHotel.py
Normal file
@@ -0,0 +1,104 @@
|
||||
from mcpi.minecraft import Minecraft
|
||||
mc = Minecraft.create()
|
||||
|
||||
import time
|
||||
import random
|
||||
|
||||
kolVo = int(input("Сколько раз появиться гостиница? "))
|
||||
|
||||
|
||||
class Building(object):
|
||||
def __init__(self, x, y, z, width, height, depth):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.depth = depth
|
||||
|
||||
def build(self):
|
||||
mc.setBlocks(self.x, self.y, self.z,
|
||||
self.x + self.width, self.y + self.height, self.z + self.depth, 4)
|
||||
|
||||
mc.setBlocks(self.x + 1, self.y + 1, self.z + 1,
|
||||
self.x + self.width - 1, self.y + self.height - 1, self.z + self.depth - 1, 0)
|
||||
|
||||
self.buildWindows()
|
||||
self.buildDoor()
|
||||
|
||||
def clear(self):
|
||||
mc.setBlocks(self.x, self.y, self.z,
|
||||
self.x + self.width, self.y + self.height, self.z + self.depth, 0)
|
||||
|
||||
def buildWindows(self):
|
||||
mc.setBlock(self.x + (self.width / 4 * 3), self.y + 2, self.z, 95)
|
||||
mc.setBlock(self.x + (self.width / 4), self.y + 2, self.z, 95)
|
||||
|
||||
def buildDoor(self):
|
||||
mc.setBlocks(self.x + (self.width / 2), self.y + 1, self.z, self.x + (self.width / 2), self.y + 2, self.z, 194)
|
||||
|
||||
|
||||
class FancyBuilding(Building):
|
||||
def upgrade(self):
|
||||
|
||||
mc.setBlocks(self.x + 1, self.y, self.z + 1,
|
||||
self.x + self.width - 1, self.y, self.z + self.depth - 1,
|
||||
35, 6)
|
||||
|
||||
|
||||
mc.setBlocks(self.x - 1, self.y, self.z - 1,
|
||||
self.x - 1, self.y, self.z + self.depth + 1,
|
||||
37)
|
||||
mc.setBlocks(self.x - 1, self.y, self.z - 1,
|
||||
self.x + self.width + 1, self.y, self.z - 1,
|
||||
37)
|
||||
mc.setBlocks(self.x + self.width + 1, self.y, self.z - 1,
|
||||
self.x + self.width + 1, self.y, self.z + self.depth + 1,
|
||||
37)
|
||||
mc.setBlocks(self.x - 1, self.y, self.z + self.depth + 1,
|
||||
self.x + self.width + 1, self.y, self.z + self.depth + 1,
|
||||
37)
|
||||
|
||||
def clear(self):
|
||||
mc.setBlocks(self.x, self.y, self.z,self.x + self.width, self.y + self.height, self.z + self.depth, 0)
|
||||
|
||||
mc.setBlocks(self.x - 1, self.y, self.z - 1,
|
||||
self.x - 1, self.y, self.z + self.depth + 1,
|
||||
0)
|
||||
mc.setBlocks(self.x - 1, self.y, self.z - 1,
|
||||
self.x + self.width + 1, self.y, self.z - 1,
|
||||
0)
|
||||
mc.setBlocks(self.x + self.width + 1, self.y, self.z - 1,
|
||||
self.x + self.width + 1, self.y, self.z + self.depth + 1,
|
||||
0)
|
||||
mc.setBlocks(self.x - 1, self.y, self.z + self.depth + 1,
|
||||
self.x + self.width + 1, self.y, self.z + self.depth + 1,
|
||||
0)
|
||||
|
||||
|
||||
pos = mc.player.getTilePos()
|
||||
x = pos.x
|
||||
y = pos.y
|
||||
z = pos.z
|
||||
|
||||
ghostHotel = FancyBuilding(x, y, z, 10, 6, 8)
|
||||
|
||||
def buildAndClear():
|
||||
|
||||
ghostHotel.build()
|
||||
ghostHotel.buildDoor()
|
||||
ghostHotel.buildWindows()
|
||||
ghostHotel.upgrade()
|
||||
|
||||
time.sleep(15)
|
||||
|
||||
ghostHotel.clear()
|
||||
|
||||
ghostHotel.x = random.randint(ghostHotel.x - 50, ghostHotel.x + 50)
|
||||
ghostHotel.z = random.randint(ghostHotel.z - 50, ghostHotel.z + 50)
|
||||
ghostHotel.y = mc.getHeight(ghostHotel.x, ghostHotel.z)
|
||||
|
||||
|
||||
for i in range(kolVo):
|
||||
buildAndClear()
|
||||
51
BookCraigRichardson/classes/ghostHouse.py
Normal file
51
BookCraigRichardson/classes/ghostHouse.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from mcpi.minecraft import Minecraft
|
||||
mc = Minecraft.create()
|
||||
import time
|
||||
import random
|
||||
|
||||
kolVo = int(input("Сколько раз появиться дом? "))
|
||||
|
||||
class Building(object):
|
||||
def __init__(self, x, y, z, width, height, depth):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.depth = depth
|
||||
def build(self):
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x + self.width, self.y + self.height, self.z + self.depth, 4)
|
||||
mc.setBlocks(self.x + 1, self.y + 1, self.z + 1, self.x + self.width - 1, self.y + self.height - 1, self.z + self.depth - 1, 0)
|
||||
|
||||
def buildDoor(self):
|
||||
mc.setBlocks(self.x + (self.width / 2), self.y + 1, self.z, self.x + (self.width / 2), self.y + 2, self.z, 0)
|
||||
|
||||
def buildWindows(self):
|
||||
mc.setBlock(self.x + (self.width / 4 * 3), self.y + 2, self.z, 0)
|
||||
mc.setBlock(self.x + (self.width / 4), self.y + 2, self.z, 0)
|
||||
|
||||
def clear(self):
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x + self.width, self.y + self.height, self.z + self.depth, 0)
|
||||
|
||||
pos = mc.player.getTilePos()
|
||||
x, y, z = pos.x, pos.y, pos.z
|
||||
|
||||
ghostHouse = Building(x, y, z, 10, 6, 8)
|
||||
|
||||
def buildAndClear():
|
||||
|
||||
ghostHouse.build()
|
||||
ghostHouse.buildDoor()
|
||||
ghostHouse.buildWindows()
|
||||
|
||||
time.sleep(15)
|
||||
|
||||
ghostHouse.clear()
|
||||
|
||||
ghostHouse.x = random.randint(ghostHouse.x - 50, ghostHouse.x + 50)
|
||||
ghostHouse.z = random.randint(ghostHouse.z - 50, ghostHouse.z + 50)
|
||||
ghostHouse.y = mc.getHeight(ghostHouse.x, ghostHouse.z)
|
||||
|
||||
|
||||
for i in range(kolVo):
|
||||
buildAndClear()
|
||||
78
BookCraigRichardson/classes/ghostTree.py
Normal file
78
BookCraigRichardson/classes/ghostTree.py
Normal file
@@ -0,0 +1,78 @@
|
||||
from mcpi.minecraft import Minecraft
|
||||
mc = Minecraft.create()
|
||||
import time
|
||||
import random
|
||||
|
||||
kolVo = int(input("Сколько раз появиться дерево? "))
|
||||
|
||||
class Building(object):
|
||||
def __init__(self, x, y, z, width, height, depth):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.depth = depth
|
||||
def build(self):
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x + self.width, self.y + self.height, self.z + self.depth, 4)
|
||||
mc.setBlocks(self.x + 1, self.y + 1, self.z + 1, self.x + self.width - 1, self.y + self.height - 1, self.z + self.depth - 1, 0)
|
||||
|
||||
def buildDoor(self):
|
||||
mc.setBlocks(self.x + (self.width / 2), self.y + 1, self.z, self.x + (self.width / 2), self.y + 2, self.z, 0)
|
||||
|
||||
def buildWindows(self):
|
||||
mc.setBlock(self.x + (self.width / 4 * 3), self.y + 2, self.z, 0)
|
||||
mc.setBlock(self.x + (self.width / 4), self.y + 2, self.z, 0)
|
||||
|
||||
def clear(self):
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x + self.width, self.y + self.height, self.z + self.depth, 0)
|
||||
|
||||
|
||||
|
||||
class Tree(Building):
|
||||
def build(self):
|
||||
wood = 17
|
||||
leaves = 18
|
||||
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x, self.y + 5, self.z, wood)
|
||||
|
||||
mc.setBlocks(self.x - 2, self.y + 6, self.z - 2, self.x + 2, self.y + 6, self.z + 2, leaves)
|
||||
mc.setBlocks(self.x - 1, self.y + 7, self.z - 1, self.x + 1, self.y + 7, self.z + 1, leaves)
|
||||
|
||||
def getInfo(self):
|
||||
return"Derevo imeet koordinati " + str(self.x) + ", " + str(self.y) + ", " + str(self.z)
|
||||
|
||||
def clear(self):
|
||||
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x, self.y + 5, self.z, 0)
|
||||
|
||||
|
||||
mc.setBlocks(self.x - 2, self.y + 6, self.z - 2, self.x + 2, self.y + 6, self.z + 2, 0)
|
||||
mc.setBlocks(self.x - 1, self.y + 7, self.z - 1, self.x + 1, self.y + 7, self.z + 1, 0)
|
||||
|
||||
|
||||
pos = mc.player.getTilePos()
|
||||
x, y, z = pos.x, pos.y, pos.z
|
||||
|
||||
|
||||
ghostTree = Tree(x, y, z, 10, 6, 8)
|
||||
|
||||
|
||||
def buildAndClear():
|
||||
|
||||
ghostTree.build()
|
||||
|
||||
mc.postToChat(ghostTree.getInfo())
|
||||
print(ghostTree.getInfo())
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
ghostTree.clear()
|
||||
|
||||
ghostTree.x = random.randint(ghostTree.x - 20, ghostTree.x + 20)
|
||||
ghostTree.z = random.randint(ghostTree.z - 20, ghostTree.z + 20)
|
||||
ghostTree.y = mc.getHeight(ghostTree.x, ghostTree.z)
|
||||
|
||||
|
||||
for i in range(kolVo):
|
||||
buildAndClear()
|
||||
81
BookCraigRichardson/classes/ghostVillage.py
Normal file
81
BookCraigRichardson/classes/ghostVillage.py
Normal file
@@ -0,0 +1,81 @@
|
||||
from mcpi.minecraft import Minecraft
|
||||
mc = Minecraft.create()
|
||||
import time
|
||||
import random
|
||||
|
||||
kolVo = int(input("Сколько раз появиться поселок? "))
|
||||
|
||||
class Building(object):
|
||||
def __init__(self, x, y, z, width, height, depth):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.depth = depth
|
||||
def build(self):
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x + self.width, self.y + self.height, self.z + self.depth, 4)
|
||||
mc.setBlocks(self.x + 1, self.y + 1, self.z + 1, self.x + self.width - 1, self.y + self.height - 1, self.z + self.depth - 1, 0)
|
||||
|
||||
def buildDoor(self):
|
||||
mc.setBlocks(self.x + (self.width / 2), self.y + 1, self.z, self.x + (self.width / 2), self.y + 2, self.z, 0)
|
||||
|
||||
def buildWindows(self):
|
||||
mc.setBlock(self.x + (self.width / 4 * 3), self.y + 2, self.z, 0)
|
||||
mc.setBlock(self.x + (self.width / 4), self.y + 2, self.z, 0)
|
||||
|
||||
def clear(self):
|
||||
mc.setBlocks(self.x, self.y, self.z, self.x + self.width, self.y + self.height, self.z + self.depth, 0)
|
||||
|
||||
pos = mc.player.getTilePos()
|
||||
x, y, z = pos.x, pos.y, pos.z
|
||||
|
||||
ghostHouse = Building(x, y, z, 10, 6, 8)
|
||||
shop = Building(x + 12, y, z, 8, 12, 10)
|
||||
scaryHouse = Building(x + 24, y, z, 5, 30, 5)
|
||||
castle = Building(x + 36, y, z, 10, 16, 16)
|
||||
|
||||
def buildAndClear():
|
||||
|
||||
ghostHouse.build()
|
||||
ghostHouse.buildDoor()
|
||||
ghostHouse.buildWindows()
|
||||
|
||||
shop.build()
|
||||
shop.buildDoor()
|
||||
shop.buildWindows()
|
||||
|
||||
scaryHouse.build()
|
||||
scaryHouse.buildDoor()
|
||||
scaryHouse.buildWindows()
|
||||
|
||||
castle.build()
|
||||
castle.buildDoor()
|
||||
castle.buildWindows()
|
||||
|
||||
time.sleep(15)
|
||||
|
||||
ghostHouse.clear()
|
||||
shop.clear()
|
||||
scaryHouse.clear()
|
||||
castle.clear()
|
||||
|
||||
ghostHouse.x = random.randint(ghostHouse.x - 50, ghostHouse.x + 50)
|
||||
ghostHouse.z = random.randint(ghostHouse.z - 50, ghostHouse.z + 50)
|
||||
ghostHouse.y = mc.getHeight(ghostHouse.x, ghostHouse.z)
|
||||
|
||||
shop.x = random.randint(shop.x - 50, shop.x + 50)
|
||||
shop.z = random.randint(shop.z - 50, shop.z + 50)
|
||||
shop.y = mc.getHeight(shop.x, shop.z)
|
||||
|
||||
scaryHouse.x = random.randint(scaryHouse.x - 50, scaryHouse.x + 50)
|
||||
scaryHouse.z = random.randint(scaryHouse.z - 50, scaryHouse.z + 50)
|
||||
scaryHouse.y = mc.getHeight(scaryHouse.x, scaryHouse.z)
|
||||
|
||||
castle.x = random.randint(castle.x - 50, castle.x + 50)
|
||||
castle.z = random.randint(castle.z - 50, castle.z + 50)
|
||||
castle.y = mc.getHeight(castle.x, castle.z)
|
||||
|
||||
|
||||
for i in range(kolVo):
|
||||
buildAndClear()
|
||||
11
BookCraigRichardson/classes/locationClass.py
Normal file
11
BookCraigRichardson/classes/locationClass.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from mcpi.minecraft import Minecraft
|
||||
mc = Minecraft.create()
|
||||
|
||||
class Location(object):
|
||||
def __init__(self, x, y, z):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
|
||||
bedroom = Location(96, 80, 341)
|
||||
mc.player.setTilePos(bedroom.x, bedroom.y, bedroom.z)
|
||||
Reference in New Issue
Block a user