Pip installable!

This commit is contained in:
Wango Fett 2017-10-26 17:05:49 +00:00
parent bcba143581
commit 0961150554
70 changed files with 127 additions and 92 deletions

3
.gitignore vendored
View File

@ -2,3 +2,6 @@
*.sw[a-p] *.sw[a-p]
*.log *.log
devlog/ devlog/
*.pyc
*.egg-info/
**/dist/

1
MANIFEST.in Normal file
View File

@ -0,0 +1 @@
recursive-include asciifarm *.json

12
Pipfile Normal file
View File

@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.python.org/simple"
name = "pypi"
verify_ssl = true
[packages]
[dev-packages]

View File

@ -1,3 +0,0 @@
#!/bin/sh
cd "`dirname "$0"`"
./playgame.py $@

0
asciifarm/__init__.py Normal file
View File

View File

View File

@ -1,30 +1,31 @@
#!/usr/bin/python3 -u #!/usr/bin/python3 -u
import argparse
import pathlib
import sys import sys
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
print("This game is written in python 3.\nRun 'python3 "+sys.argv[0]+"' or './"+sys.argv[0]+"'") print("This game is written in python 3.\nRun 'python3 "+sys.argv[0]+"' or './"+sys.argv[0]+"'")
sys.exit(-1) sys.exit(-1)
sys.path.append(sys.path[0]+"/server/") from .server import mainloop
import mainloop from .server import loader
import argparse
import loader
defaultAdresses = { defaultAdresses = {
"abstract": "asciifarm", "abstract": "asciifarm",
"unix": "asciifarm.socket", "unix": "asciifarm.socket",
"inet": "localhost:9021", "inet": "localhost:9021",
} }
default_world = pathlib.Path(__file__).parent.joinpath('maps', 'worlddata.json')
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-a", "--address", help="The address of the socket. When the socket type is 'abstract' this is just a name. When it is 'unix' this is a filename. When it is 'inet' is should be in the format 'address:port', eg 'localhost:8080'. Defaults depends on the socket type") parser.add_argument("-a", "--address", help="The address of the socket. When the socket type is 'abstract' this is just a name. When it is 'unix' this is a filename. When it is 'inet' is should be in the format 'address:port', eg 'localhost:8080'. Defaults depends on the socket type")
parser.add_argument("-s", "--socket", help="the socket type. 'unix' is unix domain sockets, 'abstract' is abstract unix domain sockets and 'inet' is inet sockets. ", choices=["abstract", "unix", "inet"], default="abstract") parser.add_argument("-s", "--socket", help="the socket type. 'unix' is unix domain sockets, 'abstract' is abstract unix domain sockets and 'inet' is inet sockets. ", choices=["abstract", "unix", "inet"], default="abstract")
parser.add_argument("-w", "--world", help="A file to load the world from.", default="maps/worlddata.json") parser.add_argument("-w", "--world", help="A file to load the world from.", default=str(default_world)) # str is only needed for python 3.5<
args = parser.parse_args() args = parser.parse_args()
address = args.address address = args.address
@ -39,4 +40,6 @@ def main():
worldData = loader.loadWorld(args.world) worldData = loader.loadWorld(args.world)
mainloop.Game(args.socket, worldData).start(address) mainloop.Game(args.socket, worldData).start(address)
main()
if __name__ == '__main__':
main()

View File

@ -8,10 +8,11 @@ if sys.version_info[0] < 3:
import argparse import argparse
import getpass import getpass
import client import json
import os import os
import os.path import os.path
import json
from . import client
thisPath = os.path.dirname(__file__) thisPath = os.path.dirname(__file__)
charMapPath = os.path.join(thisPath, "charmaps") charMapPath = os.path.join(thisPath, "charmaps")

View File

View File

View File

@ -1,5 +1,5 @@
from .. import gameobjects
import gameobjects
class Build: class Build:
""" item type for item that can be placed on the map to become something more static (like buildable walls or crops)""" """ item type for item that can be placed on the map to become something more static (like buildable walls or crops)"""

View File

@ -1,6 +1,5 @@
from .. import timeout
import timeout from .. import utils
import utils
class Fighter: class Fighter:

View File

@ -1,6 +1,5 @@
from .. import timeout
import timeout from .. import gameobjects
import gameobjects
class Growing: class Growing:

View File

@ -1,7 +1,6 @@
import gameobjects
import random import random
from .. import gameobjects
class Loot: class Loot:
""" entities that have this component will drop loot on death """ """ entities that have this component will drop loot on death """

View File

@ -1,7 +1,7 @@
import pathfinding
import random import random
from .. import pathfinding
class MonsterAi: class MonsterAi:

View File

@ -1,5 +1,4 @@
from .. import timeout
import timeout
class Move: class Move:

View File

@ -1,6 +1,6 @@
from .. import gameobjects
from .. import timeout
import timeout
import gameobjects
class Spawner: class Spawner:

View File

@ -1,6 +1,4 @@
from . import event
import event
class Entity: class Entity:

View File

@ -1,23 +1,22 @@
import random import random
import entity
import faction from . import entity
from entity import Entity from . import faction
from components.item import Item from .entity import Entity
from components.randomwalkcontroller import RandomWalkController from .components.item import Item
from components.move import Move from .components.randomwalkcontroller import RandomWalkController
from components.portal import Portal from .components.move import Move
from components.trap import Trap from .components.portal import Portal
from components.fighter import Fighter from .components.trap import Trap
from components.monsterai import MonsterAi from .components.fighter import Fighter
from components.spawner import Spawner from .components.monsterai import MonsterAi
from components.grow import Growing from .components.spawner import Spawner
from components.alignment import Alignment from .components.grow import Growing
from components.loot import Loot from .components.alignment import Alignment
from components.build import Build from .components.loot import Loot
from components.harvest import Harvest from .components.build import Build
from components.food import Food from .components.harvest import Harvest
from .components.food import Food
""" This module contains factory functions for many placable entities, and a make function to call a factory by a string name """ """ This module contains factory functions for many placable entities, and a make function to call a factory by a string name """

View File

@ -1,13 +1,13 @@
#! /usr/bin/python3 #! /usr/bin/python3
import json import json
import server
import view
import player
import queue import queue
from . import view
from . import server
from . import player
class GameServer: class GameServer:

View File

@ -1,5 +1,5 @@
from . import utils
import utils
class Grid: class Grid:

View File

@ -1,9 +1,10 @@
import random import random
import event
from . import event
neighbourdirs = {"north":(0,-1), "south":(0,1), "east":(1,0), "west":(-1,0)} neighbourdirs = {"north":(0,-1), "south":(0,1), "east":(1,0), "west":(-1,0)}
class GroundPatch: class GroundPatch:
def __init__(self, room, pos, sprite=' '): def __init__(self, room, pos, sprite=' '):

View File

@ -1,7 +1,7 @@
import os.path import os.path
import json import json
def loadRoom(roomPath): def loadRoom(roomPath):
with open(roomPath) as roomFile: with open(roomPath) as roomFile:
room = json.load(roomFile) room = json.load(roomFile)
@ -9,6 +9,7 @@ def loadRoom(roomPath):
room["places"][name] = tuple(pos) room["places"][name] = tuple(pos)
return room return room
def loadWorld(worldPath): def loadWorld(worldPath):
with open(worldPath) as worldFile: with open(worldPath) as worldFile:

View File

@ -1,9 +1,8 @@
import gameserver
import time import time
import world
import view from . import gameserver
from . import world
from . import view
class Game: class Game:

View File

@ -1,13 +1,13 @@
from .components.inventory import Inventory
from .components.inputcontroller import InputController
from .components.move import Move
from .components.fighter import Fighter
from .components.healing import Healing
from .components.alignment import Alignment
from .components.target import Target
from . import faction
from . import entity
from components.inventory import Inventory
from components.inputcontroller import InputController
from components.move import Move
from components.fighter import Fighter
from components.healing import Healing
from components.alignment import Alignment
from components.target import Target
import faction
import entity
class Player: class Player:

View File

@ -1,11 +1,11 @@
import random import random
import ground
import gameobjects from . import ground
import grid from . import gameobjects
import event from . import grid
import entity from . import event
import roomdata from . import entity
from . import roomdata
class Room: class Room:

View File

@ -1,9 +1,9 @@
import sys
import socket
import threading
import os import os
from tcommunicate import send, receive import socket
import sys
import threading
from .tcommunicate import send, receive
# Class to open a TCP Socket # Class to open a TCP Socket

View File

@ -1,5 +1,4 @@
from . import grid
import grid
# this class extracts the data to send to the clients from the world # this class extracts the data to send to the clients from the world

View File

@ -1,8 +1,7 @@
from . import room
from . import player
import room
import player
# The World class is like the model in the MVC pattern (though the rest is not that clear) # The World class is like the model in the MVC pattern (though the rest is not that clear)
class World: class World:

29
setup.py Normal file
View File

@ -0,0 +1,29 @@
from setuptools import setup, find_packages
setup(
name='asciifarm',
version='0.1.1',
description="Troido's tilde.town ASCII Farm",
long_description="TODO",
author="Troido",
author_email='troido@tilde.town',
url='http://tilde.town/~troido',
packages=find_packages(),
include_package_data=True,
data_files=[
('charmaps', ['asciifarm/charmaps/default.json', 'asciifarm/charmaps/fullwidth.json']),
],
entry_points={
'console_scripts': [
'asciifarm = asciifarm.playgame:main',
'hostfarm = asciifarm.hostfarms:main',
],
},
license='TODO',
install_requires=[
# TODO: Put requirements here -wangofett, 2017-10-26
],
tests_require=[
# TODO: put tests requirements here -wangofett, 2017-10-26
]
)

View File

@ -1,3 +0,0 @@
#!/bin/sh
cd "`dirname "$0"`"
./hostfarms.py $@ >stdout.log 2>stderr.log &