亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? psmclient.py

?? 在客戶端和服務器架構中
?? PY
?? 第 1 頁 / 共 2 頁
字號:
"""
psmclient.py - PSM Demo Client

A client to demonstrate the concept of Parallel-state machines
"""

import sys
import os
path, ignored = os.path.split(os.getcwd())
sys.path.append(path)
import actor
import socket
import select
import threading
import struct
import string
import shared.characterstatemgr
import shared.moveforward as _moveforward
import shared.moveleft as _moveleft
import shared.movebackward as _movebackward
import shared.moveright as _moveright
import shared.stopped as _stopped
import shared.standing as _standing
import shared.sitting as _sitting
import shared.layingdown as _layingdown
import shared.dead as _dead
import shared.idle as _idle
import shared.casting as _casting
import shared.fighting as _fighting
import shared.crafting as _crafting
import shared.gesturing as _gesturing
from shared.msgtypes import *

# globals
g_actorId = None           # id assigned by server for this clients actor
g_actorDict = {}           # mapping between actorId and actor instance      
g_userInput = 0            # flag indicating whether user input occured
g_inputValue = None        # the actual input value
g_port = 4701              # default port the server listens on
g_serverName = 'localhost' # default server to connect to

g_programName = 'PSM Client: '
g_inputPrompt = g_programName+'states=[w,a,s,d,x] [c,v,b] [i,u,y,o,p], 9=status, h=help, 0=exit'


def _ParseStateName(state):
  """
  Return a more readable name from the module itself
  """
  return state.__name__[7:]


def _GetInput():
  """
  Loop reading the console for input.  Returns
  when input signals to exit
  """
  
  global g_userInput
  global g_inputValue

  while 1:
    c = sys.stdin.read(1)
    if c in ['w','a','s','d','x','c','v','b','y','u','i','o','p','9','h']:
      a = threading.Lock()
      a.acquire()
      g_userInput = 1
      g_inputValue = c
      a.release()
    elif c == '0':
      return


def _RequestStateChange(s, stateToRequest):
  """
  Processes the state change request by the user.
  finds to local actor instance and then requests
  the specified state change on the actor itself.
  if succesful, make the request to the server,
  otherwise report the failure
  """
  
  actor = g_actorDict[g_actorId]
  if actor.RequestStateChange(stateToRequest):
    print g_programName+'Transitioned to state [%s], sending server request' % (_ParseStateName(stateToRequest),)
    print '(L)Actor %s: Posture [%s] Movement [%s] Action [%s]' % (g_actorId,
                                                                   _ParseStateName(actor.GetPostureState()),  \
                                                                   _ParseStateName(actor.GetMovementState()), \
                                                                   _ParseStateName(actor.GetActionState()))
    data = struct.pack("<BB", MSG_TYPE_STATE_CHANGE_REQUEST, stateToRequest.GetStateId())
    s.send(data)
  else:
    print g_programName+'Blocked from transitioning to state [%s]' % (_ParseStateName(stateToRequest),)
    print '(L)Actor %s: Posture [%s] Movement [%s] Action [%s]' % (g_actorId,
                                                                   _ParseStateName(actor.GetPostureState()),  \
                                                                   _ParseStateName(actor.GetMovementState()), \
                                                                   _ParseStateName(actor.GetActionState()))    
  print ''
  print g_inputPrompt


def _ActorStatus(s):
  """
  Displays this clients current states for each actor,
  tagging the local actor with an "(L)"
  """
  print ''
  print 'Actor Status'
  print '-----------------------------------------------------------------------------'
  for actorId, actor in g_actorDict.items():
    if g_actorId == actorId:
      print '(L)Actor %s: Posture [%s] Movement [%s] Action [%s]' % (actorId, _ParseStateName(actor.GetPostureState()),  \
                                                                   _ParseStateName(actor.GetMovementState()), \
                                                                   _ParseStateName(actor.GetActionState()))
    else:
      print '   Actor %s: Posture [%s] Movement [%s] Action [%s]' % (actorId, _ParseStateName(actor.GetPostureState()),  \
                                                                   _ParseStateName(actor.GetMovementState()), \
                                                                   _ParseStateName(actor.GetActionState()))
  print '-----------------------------------------------------------------------------'
  print ''
  print g_inputPrompt


def _ShowHelp(s):
  """
  prints extended help
  """

  print 'Press the specified key and [Enter] to cause the local actor to transition to'
  print 'the state desired. If valid to do so in the current state, a request is sent to'
  print 'the server. The resulting local actor state is displayed after each request.'
  print ''
  print 'Options:        Movement             Posture             Action'
  print '                =================    =======             ======'
  print '                w = moveforward      c = standing        i = idle'
  print '                a = moveleft         v = sitting         u = casting'
  print '                s = movebackward     b = layingdown      y = crafting'
  print '                d = moveright                            o = fighting'
  print '                x = stopped                              p = gesturing'
  print ''
  print 'Two actions are given additional functionality if there is more that 1 client'
  print 'connected.  Select casting "u" will attempt to cast a FREEZE spell on another'
  print 'actor. If successfull, it will render the affected actor unable to move.'
  print 'Selecting fighting "f" will cause an actor to attack another actor.  The fight'
  print 'is to the death, and the initiator of the attack has a hihger probability of'
  print 'success. If the initiator loses he himself will die.'
  print ''
  print 'Entering "9" causes the display of an overall status of each actor'
  print 'that is connected; an actor is assigned to each client that is logged in.'
  print 'The actor aasociated with a client is tagged with an (L). "0" exits.'
  print ''
  print g_inputPrompt


"""
This global shows up here so that we can use the
direct method reference in the dictionary.
"""

g_methodDict = {
#   input   method               args
#   ----   -------               -----
    'w'  : (_RequestStateChange, (_moveforward,)),
    'a'  : (_RequestStateChange, (_moveleft,)),
    's'  : (_RequestStateChange, (_movebackward,)),
    'd'  : (_RequestStateChange, (_moveright,)),
    'x'  : (_RequestStateChange, (_stopped,)),
    'c'  : (_RequestStateChange, (_standing,)),
    'v'  : (_RequestStateChange, (_sitting,)),
    'b'  : (_RequestStateChange, (_layingdown,)),
    'i'  : (_RequestStateChange, (_idle,)),
    'u'  : (_RequestStateChange, (_casting,)),
    'y'  : (_RequestStateChange, (_crafting,)),
    'o'  : (_RequestStateChange, (_fighting,)),
    'p'  : (_RequestStateChange, (_gesturing,)),
    '9'  : (_ActorStatus, ()),
    'h'  : (_ShowHelp, ()),
}
  
def _InvokeMethod(input, s):
  """
  Utility method that inovokes the appropriate
  method doing a lookup based on user input.
  Any args specified are passed through to
  the method.
  """
  global g_methodDict
  if g_methodDict.has_key(input):
    method, args = g_methodDict[input]
    # print 'method to call is %s with %s' % (method,s)
    apply(method, (s,)+args)


def Recv_ActorLeft(data):
  """
  A client disconnected from the server.  Remove
  that actor from this clients lookup so that is
  in sync with the servers actors.
  """
  global g_actorDict
  (actorId,) = struct.unpack("<B", data[0])
  assert g_actorId != actorId, 'server telling us we left!'
  print g_programName+'actor left, id is %s' % (actorId,)
  del g_actorDict[actorId]
  print g_inputPrompt
  return data[1:]


def Recv_NewActor(data):
  """
  A new client logged into the server. Add it to
  our actor lookup and set the initial states to those
  specified on the server
  """
  global g_actorDict
  newActorId, p, m, a = struct.unpack("<BBBB", data[0:4])

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品日韩在线一区| 国产精品国产三级国产专播品爱网 | 午夜精品爽啪视频| 看片网站欧美日韩| 91美女片黄在线观看91美女| 欧美一区二区三区公司| 亚洲欧美一区二区三区国产精品| 久久精品国产网站| 欧美无砖专区一中文字| 国产精品拍天天在线| 免费看黄色91| 欧美中文字幕亚洲一区二区va在线| 国产婷婷色一区二区三区四区| 亚洲123区在线观看| 99久久777色| 国产欧美综合在线| 久久激情综合网| 欧美一级片在线观看| 亚洲第一激情av| 色呦呦网站一区| 国产精品电影一区二区三区| 国产永久精品大片wwwapp| 日韩午夜av一区| 免费观看在线综合| 欧美精品自拍偷拍| 午夜伊人狠狠久久| 欧美视频一区二区三区四区| 亚洲精品免费在线观看| 99久久国产综合精品色伊| 国产婷婷色一区二区三区四区| 国内精品久久久久影院一蜜桃| 欧美一区二区久久| 亚洲国产色一区| 欧美日韩免费在线视频| 亚洲成人免费视频| 欧美一区二区网站| 日本不卡中文字幕| 日韩亚洲欧美在线观看| 久久99精品久久久久久| 欧美va亚洲va国产综合| 国产美女av一区二区三区| 久久久九九九九| 成人深夜福利app| 亚洲视频一区二区在线观看| 91在线高清观看| 亚洲黄色片在线观看| 欧美在线观看视频一区二区三区| 亚洲国产日韩av| 91精品在线免费| 国产成人综合在线观看| 国产精品国产自产拍高清av| 在线看不卡av| 日韩在线观看一区二区| 精品区一区二区| 国产成人免费高清| 亚洲精品老司机| 欧美一区二区成人| 国产不卡在线播放| 亚洲女同女同女同女同女同69| 精品视频一区二区不卡| 九九九精品视频| 成人欧美一区二区三区黑人麻豆| 91久久线看在观草草青青| 日韩主播视频在线| 久久综合色天天久久综合图片| 懂色av噜噜一区二区三区av| 亚洲乱码精品一二三四区日韩在线| 欧美亚洲日本一区| 国产伦精品一区二区三区视频青涩 | 日韩一区二区三区视频| 国产91精品精华液一区二区三区 | 久久99日本精品| 国产欧美视频在线观看| 91蜜桃网址入口| 日本美女一区二区三区| 国产精品欧美一区喷水| 制服丝袜av成人在线看| 高清国产午夜精品久久久久久| 亚洲一二三四区不卡| 久久人人爽人人爽| 欧美日韩国产天堂| 99久久精品一区| 精品一区二区三区免费| 一区二区三区成人| 欧美精品一区二区三区很污很色的 | 国产亚洲va综合人人澡精品| 欧美丝袜自拍制服另类| 国产高清久久久| 蜜臀av性久久久久av蜜臀妖精| 国产精品国产三级国产三级人妇| 欧美一区二区在线不卡| 欧美主播一区二区三区美女| 成人av电影在线| 国产伦精品一区二区三区视频青涩| 午夜精品久久久久| 亚洲天堂a在线| 欧美国产激情一区二区三区蜜月| 日韩欧美在线网站| 欧美性生活大片视频| 色婷婷综合久色| 成人免费视频一区二区| 国产美女在线观看一区| 久久精品国产秦先生| 亚洲v日本v欧美v久久精品| 亚洲美女一区二区三区| 国产精品久久久久一区 | 国产不卡在线视频| 国产精品1区2区3区| 麻豆精品视频在线观看视频| 午夜欧美电影在线观看| 亚洲综合999| 亚洲国产精品影院| 亚洲综合小说图片| 一区二区日韩电影| 亚洲精品久久嫩草网站秘色| 亚洲激情网站免费观看| 国产精品国产精品国产专区不蜜| 国产日本欧美一区二区| 国产视频亚洲色图| 亚洲国产精品精华液2区45| 国产午夜亚洲精品午夜鲁丝片| 欧美精品一区男女天堂| 国产午夜精品一区二区| 国产精品麻豆久久久| 国产精品传媒在线| 亚洲免费观看高清在线观看| 亚洲精品久久久久久国产精华液| 亚洲永久免费视频| 天堂成人免费av电影一区| 日韩中文字幕1| 国产在线不卡视频| 不卡的av在线播放| 色婷婷狠狠综合| 欧美日韩免费在线视频| 精品国产亚洲在线| 国产欧美一区二区精品忘忧草 | 免费高清成人在线| 国产一区二区不卡| 一本久久精品一区二区| 欧美日韩精品一区视频| 精品剧情v国产在线观看在线| 国产农村妇女毛片精品久久麻豆 | 久久99九九99精品| 国产91精品入口| 欧美色图第一页| 亚洲精品一区二区三区蜜桃下载| 国产精品二三区| 婷婷一区二区三区| 国产乱子轮精品视频| 91免费看片在线观看| 欧美老人xxxx18| 国产欧美综合在线观看第十页| 一区二区三区四区不卡在线 | 香蕉久久夜色精品国产使用方法| 亚洲成a人片在线不卡一二三区| 久久99热狠狠色一区二区| 99久久精品免费精品国产| 91精品国产综合久久久蜜臀图片 | 久久蜜桃一区二区| 一区二区三区在线不卡| 精品亚洲国内自在自线福利| 99久久久精品| 精品处破学生在线二十三| 亚洲一二三区在线观看| 国产一本一道久久香蕉| 欧美理论电影在线| 中文字幕一区在线观看视频| 免费观看在线综合色| 一本大道久久a久久精二百| 久久久久久久久97黄色工厂| 天使萌一区二区三区免费观看| 国产精品一品视频| 日韩视频一区二区三区| 亚洲夂夂婷婷色拍ww47| 国产精品99久久久| 欧美成人艳星乳罩| 一区二区三区美女| voyeur盗摄精品| 久久综合九色综合欧美亚洲| 午夜精品久久久久久| 在线视频观看一区| 国产精品视频一二三| 国产一区亚洲一区| 欧美一区二区三区影视| 亚洲国产日韩综合久久精品| 91浏览器入口在线观看| 欧美国产一区二区在线观看 | 2024国产精品| 日本不卡在线视频| 91精品婷婷国产综合久久 | 国产三区在线成人av| 蜜臀久久99精品久久久画质超高清| 欧美亚洲综合色| 1000部国产精品成人观看| 成人精品小蝌蚪| 亚洲国产高清aⅴ视频| 国产乱码精品一区二区三区五月婷 | 色综合天天综合色综合av | 日本午夜一区二区| 欧美丰满少妇xxxbbb|