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]
*.log
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
import argparse
import pathlib
import sys
if sys.version_info[0] < 3:
print("This game is written in python 3.\nRun 'python3 "+sys.argv[0]+"' or './"+sys.argv[0]+"'")
sys.exit(-1)
sys.path.append(sys.path[0]+"/server/")
import mainloop
import argparse
import loader
from .server import mainloop
from .server import loader
defaultAdresses = {
"abstract": "asciifarm",
"unix": "asciifarm.socket",
"inet": "localhost:9021",
}
}
default_world = pathlib.Path(__file__).parent.joinpath('maps', 'worlddata.json')
def main():
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("-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()
address = args.address
@ -39,4 +40,6 @@ def main():
worldData = loader.loadWorld(args.world)
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 getpass
import client
import json
import os
import os.path
import json
from . import client
thisPath = os.path.dirname(__file__)
charMapPath = os.path.join(thisPath, "charmaps")

View File

View File

View File

@ -1,5 +1,5 @@
from .. import gameobjects
import gameobjects
class Build:
""" 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 @@
import timeout
import utils
from .. import timeout
from .. import utils
class Fighter:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,23 +1,22 @@
import random
import entity
import faction
from entity import Entity
from components.item import Item
from components.randomwalkcontroller import RandomWalkController
from components.move import Move
from components.portal import Portal
from components.trap import Trap
from components.fighter import Fighter
from components.monsterai import MonsterAi
from components.spawner import Spawner
from components.grow import Growing
from components.alignment import Alignment
from components.loot import Loot
from components.build import Build
from components.harvest import Harvest
from components.food import Food
from . import entity
from . import faction
from .entity import Entity
from .components.item import Item
from .components.randomwalkcontroller import RandomWalkController
from .components.move import Move
from .components.portal import Portal
from .components.trap import Trap
from .components.fighter import Fighter
from .components.monsterai import MonsterAi
from .components.spawner import Spawner
from .components.grow import Growing
from .components.alignment import Alignment
from .components.loot import Loot
from .components.build import Build
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 """

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,8 @@
import gameserver
import time
import world
import view
from . import gameserver
from . import world
from . import view
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:

View File

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

View File

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

View File

@ -1,5 +1,4 @@
import grid
from . import grid
# 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)
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 &