-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul/simplify Item carrying. Carry one item at a time. - #9 Add item use callback - #9 Add mana collection and mycelial network - #7 Add construction spinner and buildSites - #5
- Loading branch information
Showing
13 changed files
with
310 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
__author__ = 'jripley' | ||
|
||
shroom = 26 | ||
spore = 9 | ||
node = 10 | ||
water = 30 | ||
tree = 24 | ||
grass = 25 | ||
mountain = 27 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
__author__ = 'jripley' | ||
|
||
from construct import Construct | ||
from node import Node | ||
from shroom import Shroom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from RoguePy.Game import Entity | ||
|
||
__author__ = 'jripley' | ||
|
||
class Construct(Entity): | ||
def setRequired(self, req): | ||
self.required = req | ||
return self | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__author__ = 'jripley' | ||
|
||
from RoguePy.Game import Entity | ||
|
||
|
||
class Node(Entity): | ||
active = False | ||
radius = 8 | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
from RoguePy.Game import Entity | ||
from entities import Node | ||
from sporenetwork import SporeNetwork | ||
|
||
__author__ = 'jripley' | ||
|
||
class Shroom(Entity): | ||
class Shroom(Node): | ||
active = False | ||
radius = 12 | ||
|
||
def activate(self, player): | ||
self.active = True | ||
self.player = player | ||
|
||
self.active = True | ||
|
||
|
||
self.initNetwork() | ||
|
||
def initNetwork(self): | ||
print "initing spore network" | ||
self.net = SporeNetwork(self.map) | ||
|
||
def inNetwork(self, x, y): | ||
return self.net.field[x + y * self.map.width] | ||
|
||
@property | ||
def netSize(self): | ||
return self.net.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from RoguePy.Game.Item import Item | ||
from RoguePy.UI import Colors | ||
import chars | ||
|
||
__author__ = 'jripley' | ||
|
||
spore = Item("Spore", chars.spore, Colors.white) | ||
#.desc("Plant the spore to increase the size of your mycelial network") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from RoguePy.UI import Colors | ||
from RoguePy.libtcod import libtcod | ||
import chars | ||
import config as cfg | ||
|
||
__author__ = 'jripley' | ||
|
||
class SporeNetwork(): | ||
def __init__(self, map): | ||
self.map = map | ||
|
||
self.nodes = [map.shroom] | ||
|
||
self.initField() | ||
self.calculateField() | ||
|
||
def initField(self): | ||
self.field = [0 for _i in range(self.map.width * self.map.height)] | ||
|
||
def addNode(self, node): | ||
if not node in self.nodes: | ||
self.nodes.append(node) | ||
self.calculateField(node) | ||
|
||
def removeNode(self, node): | ||
if node in self.nodes: | ||
self.nodes.remove(node) | ||
self.initField() | ||
self.calculateField() | ||
|
||
def calculateField(self, node=None): | ||
if node is None: | ||
nodes = self.nodes | ||
else: | ||
nodes = [node] | ||
|
||
w = self.map.width | ||
h = self.map.height | ||
|
||
#TODO should probably be looping on nodes, and only checking x-rad to x+rad | ||
for y in range(h): | ||
for x in range(w): | ||
for node in nodes: | ||
if self.withinRadius(x, y, node): | ||
self.field[x + y * w] = 1 | ||
break | ||
|
||
@property | ||
def size(self): | ||
return self.field.count(1) | ||
|
||
@staticmethod | ||
def withinRadius(x, y, node): | ||
dx = abs(x-node.x) | ||
dy = abs(y-node.y) | ||
R = node.radius | ||
|
||
if dx>R: | ||
return False | ||
if dy>R: | ||
return False | ||
if dx + dy <= R: | ||
return True | ||
|
||
if dx**2 + dy**2 <= R**2: | ||
return True | ||
else: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.