master
fpgajie 2026-02-04 16:25:04 +08:00
parent d63c0bac87
commit 3a58150ee8
197 changed files with 43259 additions and 11072 deletions

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<groupid>670680</groupid>
<pid>18</pid>
<password>blm523</password>
<gameHost>47.109.55.7</gameHost>
<gamePort>6311</gamePort>
</root>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<serivce-core>
<log4jPath>log4j.properties</log4jPath>
<plugin>
<id>database</id>
<class>com.taurus.core.plugin.database.DataBasePlugin</class>
<poolConfig>
<!-- 最大连接数, 默认10个 -->
<maxPool>100</maxPool>
<!-- 最小空闲连接数, 默认0个 -->
<minIdle>10</minIdle>
<!-- 配置获取连接等待超时的时间,单位是毫秒, 默认180000 -->
<maxLifetime>180000</maxLifetime>
<!--hsqldb - "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS"
Oracle - "select 1 from dual"
DB2 - "select 1 from sysibm.sysdummy1"
mysql - "select 1" -->
<validationQuery>select 1</validationQuery>
<!-- 连接超时时间,默认30000-->
<connectionTimeout>10000</connectionTimeout>
<!-- 待机超时时间,单位是毫秒, 默认60000 -->
<idleTimeout>60000</idleTimeout>
<!-- jdbc 属性 -->
<props>
<useSSL>false</useSSL>
<useUnicode>true</useUnicode>
<characterEncoding>utf-8</characterEncoding>
<!-- 服务器时区 -->
<serverTimezone>UTC</serverTimezone>
<!-- 预编译缓存 -->
<cachePrepStmts>true</cachePrepStmts>
<!-- 预编译缓存大小 -->
<prepStmtCacheSize>250</prepStmtCacheSize>
<!-- 控制长度多大的sql可以被缓存 -->
<prepStmtCacheSqlLimit>2048</prepStmtCacheSqlLimit>
</props>
</poolConfig>
<databases>
<db>
<name>db1</name>
<driverName>com.mysql.cj.jdbc.Driver</driverName>
<jdbcUrl>jdbc:mysql://192.168.0.11:6060/wb_game</jdbcUrl>
<userName>proto_ff</userName>
<password>37du_game</password>
</db>
</databases>
</plugin>
<plugin>
<id>redis</id>
<class>com.taurus.core.plugin.redis.RedisPlugin</class>
<poolConfig>
<!-- 最大连接数, 默认8个 -->
<maxTotal>80</maxTotal>
<!-- 最大空闲连接数, 默认8个 -->
<maxIdle>20</maxIdle>
<!-- 最小空闲连接数, 默认0个 -->
<minIdle>5</minIdle>
<!-- 获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1 -->
<maxWaitMillis>-1</maxWaitMillis>
<!-- 在borrow一个jedis实例时是否提前进行alidate操作, 默认false -->
<testOnBorrow>true</testOnBorrow>
<!-- 在return给pool时是否提前进行validate操作, 默认false -->
<testOnReturn>true</testOnReturn>
<!-- 表示有一个idle object evitor线程对idle object进行扫描如果validate失败
此object会被从pool中drop掉这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义, 默认true -->
<testWhileIdle>true</testWhileIdle>
<!-- 表示idle object evitor每次扫描的最多的对象数, 默认-1 -->
<numTestsPerEvictionRun>100</numTestsPerEvictionRun>
<!-- 表示一个对象至少停留在idle状态的最短时间然后才能被idle object evitor扫描并驱逐
这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义 , 默认60000-->
<minEvictableIdleTimeMillis>60000</minEvictableIdleTimeMillis>
<!-- 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认30000 -->
<timeBetweenEvictionRunsMillis>30000</timeBetweenEvictionRunsMillis>
<!-- 在minEvictableIdleTimeMillis基础上加入了至少minIdle个对象已经在pool里面了。
如果为-1evicted不会根据idle time驱逐任何对象。如果minEvictableIdleTimeMillisd大于0
则此项设置无意义且只有在timeBetweenEvictionRunsMillis大于0时才有意义默认1800000 -->
<softMinEvictableIdleTimeMillis>1800000</softMinEvictableIdleTimeMillis>
<!-- 连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true -->
<blockWhenExhausted>true</blockWhenExhausted>
</poolConfig>
<infos>
<info name="group1_db0" host="127.0.0.1" password="123456" port="6379" database="0" timeout="5000"/>
<info name="group1_db1" host="127.0.0.1" password="123456" port="6379" database="1" timeout="5000"/>
<info name="group1_db5" host="127.0.0.1" password="123456" port="6379" database="5" timeout="5000"/>
<info name="group1_db8" host="127.0.0.1" password="123456" port="6379" database="8" timeout="5000"/>
<info name="group1_db10" host="127.0.0.1" password="123456" port="6379" database="10" timeout="5000"/>
</infos>
</plugin>
</serivce-core>

View File

@ -0,0 +1,19 @@
local tag_hp = tonumber(redis.call('hget', KEYS[1],'hp'))
local bank_hp = tonumber(redis.call('hget', KEYS[2],KEYS[3]))
bank_hp = not bank_hp and 0 or bank_hp
local hp = tonumber(ARGV[1])
local opt = tonumber(ARGV[2])
if opt==0 then
if bank_hp < hp then
return 3
end
bank_hp = redis.call('hincrBy',KEYS[2],KEYS[3],-hp)
tag_hp = redis.call('hincrBy',KEYS[1],'hp',hp)
else
if tag_hp < hp then
return 4
end
bank_hp = redis.call('hincrBy',KEYS[2],KEYS[3],hp)
tag_hp = redis.call('hincrBy',KEYS[1],'hp',-hp)
end
return {tag_hp,bank_hp}

View File

@ -0,0 +1,20 @@
log4j.rootLogger = INFO,consoleAppender,fileAppender
# ConsoleAppender
log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%t] %c{2} %3x - %m%n
# Regular FileAppender
log4j.appender.fileAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.fileAppender.File=${WORKDIR}/logs/web_main.log
log4j.appender.fileAppender.layout.ConversionPattern=%d{dd MMM yyyy | HH:mm:ss,SSS} | %-5p | %t | %c{3} | %3x | %m%n
log4j.appender.fileAppender.Encoding=UTF-8
log4j.appender.fileAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.dailyFile.Append=true
# The file is rolled over very day
log4j.appender.fileAppender.DatePattern ='.'yyyy-MM-dd

View File

@ -0,0 +1,25 @@
-- redis.call('select',0)
local mgr_hp = tonumber(redis.call('hget', KEYS[1],'hp'))
local tag_hp = tonumber(redis.call('hget', KEYS[2],'hp'))
local ulev = tonumber(ARGV[2])
local hp = tonumber(ARGV[1])
if ulev == 3 or ulev == 2 then
if hp > 0 and mgr_hp <hp then
return 3
else
if hp < 0 and tag_hp < math.abs(hp) then
return 4
end
mgr_hp = redis.call('hincrBy',KEYS[1],'hp',-hp)
tag_hp = redis.call('hincrBy',KEYS[2],'hp',hp)
end
else
tag_hp = tag_hp + hp
if tag_hp < 0 then
return 4
else
redis.call('hincrBy',KEYS[2],'hp',hp)
end
end
return {mgr_hp,tag_hp}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<groupid>670680</groupid>
<pid>18</pid>
<password>blm523</password>
<gameHost>47.109.55.7</gameHost>
<gamePort>6311</gamePort>
</root>

View File

@ -0,0 +1,10 @@
local reward_hp = tonumber(redis.call('get', KEYS[1]))
local hp = tonumber(ARGV[1])
local tag_hp = 0
if hp > 0 and reward_hp < hp then
return 3
else
reward_hp = redis.call('incrBy',KEYS[1],-hp)
tag_hp = redis.call('hincrBy',KEYS[2],'hp',hp)
end
return {reward_hp,tag_hp}

View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<serivce-core>
<log4jPath>log4j.properties</log4jPath>
<plugin>
<id>database</id>
<class>com.taurus.core.plugin.database.DataBasePlugin</class>
<poolConfig>
<!-- 最大连接数, 默认10个 -->
<maxPool>100</maxPool>
<!-- 最小空闲连接数, 默认0个 -->
<minIdle>10</minIdle>
<!-- 配置获取连接等待超时的时间,单位是毫秒, 默认180000 -->
<maxLifetime>180000</maxLifetime>
<!--hsqldb - "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS"
Oracle - "select 1 from dual"
DB2 - "select 1 from sysibm.sysdummy1"
mysql - "select 1" -->
<validationQuery>select 1</validationQuery>
<!-- 连接超时时间,默认30000-->
<connectionTimeout>10000</connectionTimeout>
<!-- 待机超时时间,单位是毫秒, 默认60000 -->
<idleTimeout>60000</idleTimeout>
<!-- jdbc 属性 -->
<props>
<useSSL>false</useSSL>
<useUnicode>true</useUnicode>
<characterEncoding>utf-8</characterEncoding>
<!-- 服务器时区 -->
<serverTimezone>UTC</serverTimezone>
<!-- 预编译缓存 -->
<cachePrepStmts>true</cachePrepStmts>
<!-- 预编译缓存大小 -->
<prepStmtCacheSize>250</prepStmtCacheSize>
<!-- 控制长度多大的sql可以被缓存 -->
<prepStmtCacheSqlLimit>2048</prepStmtCacheSqlLimit>
</props>
</poolConfig>
<databases>
<db>
<name>db1</name>
<driverName>com.mysql.cj.jdbc.Driver</driverName>
<jdbcUrl>jdbc:mysql://47.109.55.7:8060/wb_game</jdbcUrl>
<userName>root</userName>
<password>6KYnXJjGhxNceF8e</password>
</db>
</databases>
</plugin>
<plugin>
<id>redis</id>
<class>com.taurus.core.plugin.redis.RedisPlugin</class>
<poolConfig>
<!-- 最大连接数, 默认8个 -->
<maxTotal>80</maxTotal>
<!-- 最大空闲连接数, 默认8个 -->
<maxIdle>20</maxIdle>
<!-- 最小空闲连接数, 默认0个 -->
<minIdle>5</minIdle>
<!-- 获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1 -->
<maxWaitMillis>-1</maxWaitMillis>
<!-- 在borrow一个jedis实例时是否提前进行alidate操作, 默认false -->
<testOnBorrow>true</testOnBorrow>
<!-- 在return给pool时是否提前进行validate操作, 默认false -->
<testOnReturn>true</testOnReturn>
<!-- 表示有一个idle object evitor线程对idle object进行扫描如果validate失败
此object会被从pool中drop掉这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义, 默认true -->
<testWhileIdle>true</testWhileIdle>
<!-- 表示idle object evitor每次扫描的最多的对象数, 默认-1 -->
<numTestsPerEvictionRun>100</numTestsPerEvictionRun>
<!-- 表示一个对象至少停留在idle状态的最短时间然后才能被idle object evitor扫描并驱逐
这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义 , 默认60000-->
<minEvictableIdleTimeMillis>60000</minEvictableIdleTimeMillis>
<!-- 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认30000 -->
<timeBetweenEvictionRunsMillis>30000</timeBetweenEvictionRunsMillis>
<!-- 在minEvictableIdleTimeMillis基础上加入了至少minIdle个对象已经在pool里面了。
如果为-1evicted不会根据idle time驱逐任何对象。如果minEvictableIdleTimeMillisd大于0
则此项设置无意义且只有在timeBetweenEvictionRunsMillis大于0时才有意义默认1800000 -->
<softMinEvictableIdleTimeMillis>1800000</softMinEvictableIdleTimeMillis>
<!-- 连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true -->
<blockWhenExhausted>true</blockWhenExhausted>
</poolConfig>
<infos>
<info name="group1_db0" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="cssq@2020" port="6379" database="0" timeout="5000"/>
<info name="group1_db1" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="cssq@2020" port="6379" database="1" timeout="5000"/>
<info name="group1_db2" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="cssq@2020" port="6379" database="2" timeout="5000"/>
<info name="group1_db5" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="cssq@2020" port="6379" database="5" timeout="5000"/>
<info name="group1_db8" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="cssq@2020" port="6379" database="8" timeout="5000"/>
<info name="group1_db9" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="cssq@2020" port="6379" database="9" timeout="5000"/>
<info name="group1_db10" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="cssq@2020" port="6379" database="10" timeout="5000"/>
<info name="group1_db11" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="cssq@2020" port="6379" database="11" timeout="5000"/>
<info name="tmp_group1_db9" host="r-2vc0x3clldkj94synhpd.redis.cn-chengdu.rds.aliyuncs.com" password="654sads" port="6479" database="9" timeout="5000"/>
</infos>
</plugin>
</serivce-core>

View File

@ -0,0 +1,12 @@
local mgr_hp = tonumber(redis.call('hget', KEYS[1],'hp'))
local tag_hp = tonumber(redis.call('hget', KEYS[2],'hp'))
mgr_hp = not mgr_hp and 0 or mgr_hp
tag_hp = not tag_hp and 0 or tag_hp
local hp = tonumber(ARGV[1])
if hp > 0 and mgr_hp <hp then
return 3
else
mgr_hp = redis.call('hincrBy',KEYS[1],'hp',-hp)
tag_hp = redis.call('hincrBy',KEYS[2],'hp',hp)
end
return {mgr_hp,tag_hp}

View File

@ -0,0 +1,19 @@
local tag_hp = tonumber(redis.call('hget', KEYS[1],'hp'))
local bank_hp = tonumber(redis.call('hget', KEYS[2],KEYS[3]))
bank_hp = not bank_hp and 0 or bank_hp
local hp = tonumber(ARGV[1])
local opt = tonumber(ARGV[2])
if opt==0 then
if bank_hp < hp then
return 3
end
bank_hp = redis.call('hincrBy',KEYS[2],KEYS[3],-hp)
tag_hp = redis.call('hincrBy',KEYS[1],'hp',hp)
else
if tag_hp < hp then
return 4
end
bank_hp = redis.call('hincrBy',KEYS[2],KEYS[3],hp)
tag_hp = redis.call('hincrBy',KEYS[1],'hp',-hp)
end
return {tag_hp,bank_hp}

View File

@ -0,0 +1,20 @@
log4j.rootLogger = INFO,consoleAppender,fileAppender
# ConsoleAppender
log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%t] %c{2} %3x - %m%n
# Regular FileAppender
log4j.appender.fileAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.fileAppender.File=${WORKDIR}/logs/web_main.log
log4j.appender.fileAppender.layout.ConversionPattern=%d{dd MMM yyyy | HH:mm:ss,SSS} | %-5p | %t | %c{3} | %3x | %m%n
log4j.appender.fileAppender.Encoding=UTF-8
log4j.appender.fileAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.dailyFile.Append=true
# The file is rolled over very day
log4j.appender.fileAppender.DatePattern ='.'yyyy-MM-dd

View File

@ -0,0 +1,25 @@
-- redis.call('select',0)
local mgr_hp = tonumber(redis.call('hget', KEYS[1],'hp'))
local tag_hp = tonumber(redis.call('hget', KEYS[2],'hp'))
local ulev = tonumber(ARGV[2])
local hp = tonumber(ARGV[1])
if ulev == 3 or ulev == 2 then
if hp > 0 and mgr_hp <hp then
return 3
else
if hp < 0 and tag_hp < math.abs(hp) then
return 4
end
mgr_hp = redis.call('hincrBy',KEYS[1],'hp',-hp)
tag_hp = redis.call('hincrBy',KEYS[2],'hp',hp)
end
else
tag_hp = tag_hp + hp
if tag_hp < 0 then
return 4
else
redis.call('hincrBy',KEYS[2],'hp',hp)
end
end
return {mgr_hp,tag_hp}

View File

@ -0,0 +1,10 @@
local reward_hp = tonumber(redis.call('get', KEYS[1]))
local hp = tonumber(ARGV[1])
local tag_hp = 0
if hp > 0 and reward_hp < hp then
return 3
else
reward_hp = redis.call('incrBy',KEYS[1],-hp)
tag_hp = redis.call('hincrBy',KEYS[2],'hp',hp)
end
return {reward_hp,tag_hp}

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<serivce-core>
<log4jPath>log4j.properties</log4jPath>
<plugin>
<id>database</id>
<class>com.taurus.core.plugin.database.DataBasePlugin</class>
<poolConfig>
<!-- 最大连接数, 默认10个 -->
<maxPool>100</maxPool>
<!-- 最小空闲连接数, 默认0个 -->
<minIdle>1</minIdle>
<!-- 配置获取连接等待超时的时间,单位是毫秒, 默认180000 -->
<maxLifetime>180000</maxLifetime>
<!--hsqldb - "select 1 from INFORMATION_SCHEMA.SYSTEM_USERS"
Oracle - "select 1 from dual"
DB2 - "select 1 from sysibm.sysdummy1"
mysql - "select 1" -->
<validationQuery>select 1</validationQuery>
<!-- 连接超时时间,默认30000-->
<connectionTimeout>10000</connectionTimeout>
<!-- 待机超时时间,单位是毫秒, 默认60000 -->
<idleTimeout>60000</idleTimeout>
<!-- jdbc 属性 -->
<props>
<useSSL>false</useSSL>
<useUnicode>true</useUnicode>
<characterEncoding>utf-8</characterEncoding>
<!-- 服务器时区 -->
<serverTimezone>UTC</serverTimezone>
<!-- 预编译缓存 -->
<cachePrepStmts>true</cachePrepStmts>
<!-- 预编译缓存大小 -->
<prepStmtCacheSize>250</prepStmtCacheSize>
<!-- 控制长度多大的sql可以被缓存 -->
<prepStmtCacheSqlLimit>2048</prepStmtCacheSqlLimit>
</props>
</poolConfig>
<databases>
<db>
<name>db1</name>
<driverName>com.mysql.cj.jdbc.Driver</driverName>
<jdbcUrl>jdbc:mysql://192.168.0.11:6060/wb_game</jdbcUrl>
<userName>proto_ff</userName>
<password>37du_game</password>
</db>
</databases>
</plugin>
<plugin>
<id>redis</id>
<class>com.taurus.core.plugin.redis.RedisPlugin</class>
<poolConfig>
<!-- 最大连接数, 默认8个 -->
<maxTotal>80</maxTotal>
<!-- 最大空闲连接数, 默认8个 -->
<maxIdle>8</maxIdle>
<!-- 最小空闲连接数, 默认0个 -->
<minIdle>2</minIdle>
<!-- 获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1 -->
<maxWaitMillis>-1</maxWaitMillis>
<!-- 在borrow一个jedis实例时是否提前进行alidate操作, 默认false -->
<testOnBorrow>true</testOnBorrow>
<!-- 在return给pool时是否提前进行validate操作, 默认false -->
<testOnReturn>true</testOnReturn>
<!-- 表示有一个idle object evitor线程对idle object进行扫描如果validate失败
此object会被从pool中drop掉这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义, 默认true -->
<testWhileIdle>true</testWhileIdle>
<!-- 表示idle object evitor每次扫描的最多的对象数, 默认-1 -->
<numTestsPerEvictionRun>100</numTestsPerEvictionRun>
<!-- 表示一个对象至少停留在idle状态的最短时间然后才能被idle object evitor扫描并驱逐
这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义 , 默认60000-->
<minEvictableIdleTimeMillis>60000</minEvictableIdleTimeMillis>
<!-- 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认30000 -->
<timeBetweenEvictionRunsMillis>30000</timeBetweenEvictionRunsMillis>
<!-- 在minEvictableIdleTimeMillis基础上加入了至少minIdle个对象已经在pool里面了。
如果为-1evicted不会根据idle time驱逐任何对象。如果minEvictableIdleTimeMillisd大于0
则此项设置无意义且只有在timeBetweenEvictionRunsMillis大于0时才有意义默认1800000 -->
<softMinEvictableIdleTimeMillis>1800000</softMinEvictableIdleTimeMillis>
<!-- 连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true -->
<blockWhenExhausted>true</blockWhenExhausted>
</poolConfig>
<infos>
<info name="group1_db0" host="127.0.0.1" password="123456" port="6379" database="0" timeout="5000"/>
<info name="group1_db1" host="127.0.0.1" password="123456" port="6379" database="1" timeout="5000"/>
<info name="group1_db2" host="127.0.0.1" password="123456" port="6379" database="2" timeout="5000"/>
<info name="group1_db5" host="127.0.0.1" password="123456" port="6379" database="5" timeout="5000"/>
<info name="group1_db8" host="127.0.0.1" password="123456" port="6379" database="8" timeout="5000"/>
<info name="group1_db9" host="127.0.0.1" password="123456" port="6379" database="9" timeout="5000"/>
<info name="group1_db10" host="127.0.0.1" password="123456" port="6379" database="10" timeout="5000"/>
<info name="group1_db11" host="127.0.0.1" password="123456" port="6379" database="11" timeout="5000"/>
</infos>
</plugin>
</serivce-core>

View File

@ -0,0 +1,12 @@
local mgr_hp = tonumber(redis.call('hget', KEYS[1],'hp'))
local tag_hp = tonumber(redis.call('hget', KEYS[2],'hp'))
mgr_hp = not mgr_hp and 0 or mgr_hp
tag_hp = not tag_hp and 0 or tag_hp
local hp = tonumber(ARGV[1])
if hp > 0 and mgr_hp <hp then
return 3
else
mgr_hp = redis.call('hincrBy',KEYS[1],'hp',-hp)
tag_hp = redis.call('hincrBy',KEYS[2],'hp',hp)
end
return {mgr_hp,tag_hp}

View File

@ -43,6 +43,8 @@ public class MainServer extends Extension {
public static int pid;
private static String password;
private static Map<String, String> robotmap;
private static String gameHost;
private static String gamePort;
@ -119,9 +121,107 @@ public class MainServer extends Extension {
robotUser.setGamePort(gamePort);
robotUser.setRobotGroupid(groupid);
robotUser.setRobotPid(pid);
robotUser.setHuNanChangSha();
/*
Thread eventThread = new Thread(() -> {
while (true) {
try {
if(!robotUser.isLogin){
robotUser.login();
}
//2、链接
//判断是否链接
if(!robotUser.getisconnect()){
robotUser.connectGame();
}else{
robotUser.renconnect();
}
//检测是否断开链接
robotUser.checkIsConnect();
//4、加入房间
if(robotUser.getStatus()==0){
//没状态时候进入加入房间
robotUser.joinRoom();
}
//3、创建房间
if(robotUser.getStatus()==ROBOTEventType.ROBOT_UNUSE){
//没状态时候进入创建房间
robotUser.createRoom();
}
System.out.println("robotUser.getIntoRoomTime()"+robotUser.getIntoRoomTime());
System.out.println("robGetTiem"+robotUser.getTime());
if(robotUser.getIntoRoomTime()+6<=robotUser.getTime()){
//5、退出房间
robotUser.outoRoom();
}
Thread.sleep(10000);
} catch (InterruptedException e) {
break;
} catch (Exception e) {
}
}
}, Integer.parseInt(entry.getKey())+"");
eventThread.setDaemon(true); // 设置为守护线程
eventThread.start();*/
robotUserMap.put(Integer.parseInt(entry.getKey()), robotUser);
}
/*for(Map.Entry<Integer, RobotUser> entry : robotUserMap.entrySet()) {
TPServer.me().getTimerPool().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
System.out.println(entry.getKey()+":"+entry.getValue());
RobotUser robotUser = entry.getValue();
//1、登录
//判断是否登录
if(!robotUser.isLogin){
robotUser.login();
}
//2、链接
//判断是否链接
System.out.println("robotUser.isconnect"+robotUser.getisconnect());
if(!robotUser.getisconnect()){
robotUser.connectGame();
}else{
robotUser.renconnect();
}
//检测是否断开链接
robotUser.checkIsConnect();
//4、加入房间
if(robotUser.getStatus()==0){
//没状态时候进入加入房间
robotUser.joinRoom();
}
//3、创建房间
if(robotUser.getStatus()==ROBOTEventType.ROBOT_UNUSE){
//没状态时候进入创建房间
robotUser.createRoom();
}
System.out.println("robotUser.getIntoRoomTime()"+robotUser.getIntoRoomTime());
System.out.println("robGetTiem"+robotUser.getTime());
if(robotUser.getIntoRoomTime()+6<=robotUser.getTime()){
//5、退出房间
robotUser.outoRoom();
}
}
}, 0, 6 ,TimeUnit.SECONDS);
}*/
// 2. 定时器只负责创建机器人连接
TPServer.me().getTimerPool().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@ -148,28 +248,23 @@ public class MainServer extends Extension {
//检测是否断开链接
robotUser.checkIsConnect();
//3、创建房间
//4、加入房间
if(robotUser.getStatus()==0){
//没状态时候进入创建房间
//没状态时候进入加入房间
robotUser.joinRoom();
}
//3、创建房间
if(robotUser.getStatus()==ROBOTEventType.ROBOT_UNUSE){
//没状态时候进入创建房间
robotUser.createRoom();
}
//4、加入房间
//5、退出房间
//6、工作
System.out.println("robotUser.getIntoRoomTime()"+robotUser.getIntoRoomTime());
System.out.println("robGetTiem"+robotUser.getTime());
if(robotUser.getIntoRoomTime()+6<=robotUser.getTime()){
//5、退出房间
robotUser.outoRoom();
}
}
@ -186,7 +281,7 @@ public class MainServer extends Extension {
// System.out.println("机器人返回结果: " + s);
}
}, 0, 3 ,TimeUnit.SECONDS);
}, 0, 5 ,TimeUnit.SECONDS);
} catch (Exception e) {
// System.out.println("创建机器人连接失败" + e);
@ -197,11 +292,12 @@ public class MainServer extends Extension {
// 独立的事件处理线程
private void startNetEventThread() {
Thread eventThread = new Thread(() -> {
while (true) {
NetManager.processEvents();
try {
Thread.sleep(2);
Thread.sleep(100);
} catch (InterruptedException e) {
break;
} catch (Exception e) {

View File

@ -16,10 +16,8 @@ import com.robotcm.taurus.client.Message;
import com.robotcm.taurus.client.TaurusClient;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
public class HuNanChangSha {
@ -28,6 +26,14 @@ public class HuNanChangSha {
public static boolean isTinChi = false;
public static boolean isTinPeng = false;
private int robotid=0;
public void setRobotid(int robotid) {
this.robotid = robotid;
}
public int getRobotid() {
return robotid;
}
// private static final Logger log = Logger.getLogger(DoTest.class);
@ -39,6 +45,10 @@ public class HuNanChangSha {
private List<Integer> changShaCardInhand = new ArrayList<>();
public List<Integer> getChangShaCardInhand() {
return changShaCardInhand;
}
private Map<Integer, Integer> chuGuoPainum = new HashMap<>();
@ -85,9 +95,6 @@ public class HuNanChangSha {
return chowGroup;
}
public List<Integer> getChangShaCardInhand() {
return changShaCardInhand;
}
public List<Integer> getChuGuoCardInhand() {
return changShachuguopai;
@ -125,7 +132,7 @@ public class HuNanChangSha {
* @param message
* @return
*/
public String getCard(String command, Message message, TaurusClient client, Map<String, Object> mapclient) {
public String getCard(String command, Message message, TaurusClient client) {
if (command.equalsIgnoreCase("819")) {
ITObject param = message.param;
if (param == null) {
@ -139,7 +146,8 @@ public class HuNanChangSha {
int drawnCard = param.getInt("card");
changShaSuanFaTest.drawnCards = drawnCard;//存储摸到的牌
changShaCardInhand.add(drawnCard);
System.out.println("param.getInt(player)" + param.getInt("player") );
System.out.println("摸到的牌 +++++++++ " + drawnCard);
if (jedis222.hget("{robortInfo}:" + player, "circleId") != null && jedis222.hget("{robortInfo}:" + player, "pid") != null) {
String circleId = jedis222.hget("{robortInfo}:" + player, "circleId");
String pid = jedis222.hget("{robortInfo}:" + player, "pid");
@ -208,6 +216,20 @@ public class HuNanChangSha {
return null;
}
/**
*
* @param handCard
*/
public void updateHandCard(List<Integer> handCard) {
changShaCardInhand.clear();
changShaCardInhand.addAll(handCard);
}
public void updateOutCard(List<Integer> outCard) {
changShachuguopai.clear();
changShachuguopai.addAll(outCard);
}
public static int[][] countTiles(List<Integer> cardInHand) {
int[][] counts = new int[5][10]; // 类型×值
@ -301,7 +323,7 @@ public class HuNanChangSha {
// log.info("tipList" +tipList);
ITObject params = TObject.newInstance();
int card = 0;
getChangShaCardInhand();
//循环
List<Integer> yupanhandcard = new ArrayList<>();
yupanhandcard.addAll(changShaCardInhand);
@ -1793,8 +1815,10 @@ public class HuNanChangSha {
// 将当前出的牌添加到历史出牌列表
changShachuguopai.add(cardToOut);
System.out.println("changShachuguopai ++++ :"+changShachuguopai);
// 从手牌中移除
changShaCardInhand.remove(Integer.valueOf(cardToOut));
System.out.println("打过后的手牌 +++ " + changShaCardInhand);
params.putString("session", session + "," + token);
client.send("611", params, response -> {
@ -1846,7 +1870,14 @@ public class HuNanChangSha {
}
public static void main(String[] args) {
HuNanChangSha huNanChangSha = new HuNanChangSha();
String str = "[107, 202, 204, 103, 109, 101, 108, 201, 109, 105, 207, 209, 202]";
String cleanedStr = str.substring(1, str.length() - 1);
List<Integer> list = Arrays.stream(cleanedStr.split(", "))
.map(Integer::parseInt)
.collect(Collectors.toList());
System.out.println(list);
/*HuNanChangSha huNanChangSha = new HuNanChangSha();
ITObject params = TObject.newInstance();
TaurusClient tc = new TaurusClient("47.109.55.7", "10", TaurusClient.ConnectionProtocol.Tcp);
List<Integer> hands1 = new ArrayList<>();
@ -1922,6 +1953,8 @@ public class HuNanChangSha {
//huNanChangSha.chowGroup.add(205);
String res = huNanChangSha.actionCard(params, tc);
System.out.println(res);
*/
}

View File

@ -1057,7 +1057,7 @@ public class JiQiRens {
HuNanChangSha.drawCard(command, message);
} else if ("819".equalsIgnoreCase(command)) {
//摸牌
huNanChangSha.getCard(command, message,null,null);
huNanChangSha.getCard(command, message,client);
} else if ("813".equalsIgnoreCase(command)) {//出牌提示
huNanChangSha.outCard(client,playerOutcardsMap,playerchisMap,playerpengsMap,playermingsMap,playerzisMap);

View File

@ -29,6 +29,7 @@ import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@ -151,6 +152,43 @@ public class AccountBusiness extends Controller {
return resData;
}
public final ITObject fastLogin(int userid) throws Exception {
Jedis jedis = Redis.use("group1_db0").getJedis();
ITObject resData = null;
try {
Set<String> usertoken = jedis.smembers("{user}:"+userid+"_token");
if (usertoken.size()<=0){
return null;
}
String token = "";
for (String item : usertoken) {
token = item;
}
String session ="{user}:"+userid;
AccountBean acc_bean = AccountCache.getAccount(session);
resData = fillLoginData(session, acc_bean.id);
String idPwdBan = Redis.use("group1_db0").get(acc_bean.id+"_login_ban");
if (StringUtil.isNotEmpty(idPwdBan))
{
logger.error("id:"+acc_bean.id+" ban login");
throw new WebException(ErrorCode.BAN_LOGIN);
}
resData.putString("token", token);
return resData;
}catch (Exception e){
}finally {
jedis.close();
}
return resData;
}
public final ITObject idPasswordLogin(int id, String password) throws Exception {
logger.info("id:" + id + " login");

View File

@ -576,7 +576,7 @@ public class lianjiejiqiren {
TaurusClient taurusClient = (TaurusClient) entry.getValue();
if (client.equals(taurusClient)) {
//摸牌
huNanChangSha.getCard(command, message, taurusClient,mapclient);
huNanChangSha.getCard(command, message, taurusClient);
}
}

View File

@ -1,23 +1,30 @@
package com.robotcm.taurus.robot;
import com.data.cache.GroupCache;
import com.robotcm.hunan.HuNanChangSha;
import com.robotcm.taurus.client.Message;
import com.robotcm.taurus.client.MessageResponse;
import com.robotcm.taurus.client.SocketCode;
import com.robotcm.taurus.client.TaurusClient;
import com.robotcm.taurus.client.business.AccountBusiness;
import com.robotcm.taurus.client.business.GroupRoomBusiness;
import com.robotcm.taurus.newRobot.jiqiren;
import com.robotcm.taurus.util.ChangShaSuanFaTest;
import com.robotcm.taurus.util.ROBOTEventType;
import com.robotcm.taurus.util.TinHuChi;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.ITObject;
import com.taurus.core.entity.TArray;
import com.taurus.core.entity.TObject;
import com.taurus.core.events.Event;
import com.taurus.core.events.IEventListener;
import com.taurus.core.plugin.redis.Redis;
import com.taurus.core.util.ICallback;
import com.taurus.core.util.Logger;
import com.taurus.core.util.StringUtil;
import redis.clients.jedis.Jedis;
import java.util.Map;
import java.util.Set;
import java.util.*;
public class RobotUser {
@ -25,6 +32,9 @@ public class RobotUser {
public boolean isLogin = false;
private HuNanChangSha huNanChangSha;
private final static Logger log;
static {
@ -41,15 +51,45 @@ public class RobotUser {
public int robotGroupid;
public int robotPid;
private Map<Integer, List<Integer>> playerOutcardsMap = new HashMap<>();
private Map<Integer, List<Integer>> playerchisMap = new HashMap<>();
private Map<Integer, List<Integer>> playerpengsMap = new HashMap<>();
private Map<Integer, List<Integer>> playermingsMap = new HashMap<>();
private Map<Integer, List<Integer>> playerzisMap = new HashMap<>();
private String token;
private int seat;
private int outcardseat;
public int intoRoomTime; //进入房间时间戳
public TaurusClient client = null;
public int currentRoomId;//当然房间id
public static TaurusClient client = null;
private String loginsession;
public void setSeat(int seat) {
this.seat = seat;
}
public int getSeat() {
return seat;
}
public void setOutcardseat(int outcardseat) {
this.outcardseat = outcardseat;
}
public int getOutcardseat() {
return outcardseat;
}
public void setisconnect(boolean isconnect) {
this.isconnect = isconnect;
}
@ -117,6 +157,19 @@ public class RobotUser {
return gamePort;
}
public void setCurrentRoomId(int currentRoomId) {
this.currentRoomId = currentRoomId;
}
public int getCurrentRoomId() {
return currentRoomId;
}
public void setHuNanChangSha() {
huNanChangSha = new HuNanChangSha();
huNanChangSha.setRobotid(robotid);
}
/**
*
*/
@ -134,16 +187,29 @@ public class RobotUser {
AccountBusiness accountBusiness = null;
accountBusiness = new AccountBusiness();
try {
object = accountBusiness.idPasswordLogin(robotid, getPassword());
//先快速登录
object = accountBusiness.fastLogin(robotid);
System.out.println("object:"+object);
if(object==null){
object = accountBusiness.idPasswordLogin(robotid, getPassword());
}
if (object != null) {
System.out.println("login:"+object);
ITObject validate = TObject.newInstance();
validate.putString("token", object.getString("token"));
token = object.getString("token");
loginsession = accountBusiness.getSession();
if (loginsession != null) {
this.isLogin = true;
setLoginsession(loginsession);
//判断是否有房间
if(object.getTObject("account")!=null){
ITObject validate = TObject.newInstance();
validate.putString("token", object.getString("token"));
token = object.getString("token");
loginsession = "{user}:"+robotid;
if (loginsession != null) {
this.isLogin = true;
setLoginsession(loginsession);
}
if(object.getTObject("account").get("roomid")!=null){
String roomid = object.getTObject("account").get("roomid").toString();
setCurrentRoomId(Integer.parseInt(roomid));
connectGame();
joinToRoomId(roomid);
}
}
}
@ -158,12 +224,19 @@ public class RobotUser {
client = new TaurusClient(gameHost+":"+gamePort, String.valueOf(robotid), TaurusClient.ConnectionProtocol.Tcp);
client.setSession(loginsession);
client.connect();
jianting(client);
setisconnect(client.isConnected());
}else{
System.out.println("reconnect");
System.out.println("client.isConnected()"+client.isConnected());
if(client.isConnected()){
this.isconnect = true;
}else{
System.out.println("reconnect"+client.getGameID());
client = new TaurusClient(gameHost+":"+gamePort, String.valueOf(robotid), TaurusClient.ConnectionProtocol.Tcp);
client.setSession(loginsession);
client.connect();
//jianting(client);
setisconnect(client.isConnected());
}
}
@ -181,6 +254,7 @@ public class RobotUser {
if(client!=null){
if(client.isConnected()){
client.connect();
//jianting(client);
setisconnect(client.isConnected());
}
}
@ -190,17 +264,28 @@ public class RobotUser {
*
*/
public void checkIsConnect(){
System.out.println("checkIsConnect:"+robotid+"==="+getStatus());
System.out.println("checkIsConnectgetId:"+robotid+"==="+client.getId());
System.out.println("checkIsConnectgetGameID:"+robotid+"==="+client.getGameID());
if(isLogin&&client!=null){
System.out.println("connectid:"+client.getId());
setisconnect(client.isConnected());
//判断是否在房间
}
}
/**
* 退
*/
public void logoutRoom(){
public void joinToRoomId(String roomid){
try {
String room = "room:" + roomid;
ITObject roomInfos = GroupRoomBusiness.joinRoom(robotGroupid, room, loginsession, null);
log.info("房间数据数据时数据1213234453543545------" + roomInfos);
doJoinRoom(robotid); //进入房间
ready(); //准备
setIntoRoomTime(getTime());
}catch(Exception e){
e.printStackTrace();
}
}
@ -209,6 +294,75 @@ public class RobotUser {
*/
public void joinRoom(){
System.out.println("joinRoom:"+robotid);
//检查是否有真人的房间
//查找真人
Set<String> rooms = null;
Jedis jedis11 = Redis.use("group1_db11").getJedis();
Jedis jedis2 = Redis.use("group1_db2").getJedis();
Jedis jedis0 = Redis.use("group1_db0").getJedis();
try {
int min_value = 100000;
int max_value = 999999;
String grooms_key = GroupCache.genRoomsKey(robotGroupid);
rooms = jedis11.zrevrangeByScore(grooms_key, max_value, min_value);
long time = System.currentTimeMillis() / 1000;
System.out.println("rooms:"+rooms);
if (rooms.size()>0) {
for (String room : rooms) {
//limitInRoom
List<String> room_list = jedis0.hmget(room, "fake", "status", "gpid", "id", "times", "players", "create_time","limitInRoom", "fake_existTime");
//1、气氛桌过滤
String fake_json = room_list.get(0);
if (fake_json != null)
{
continue;
}
String pid = room_list.get(2);
System.out.println("pid:"+pid);
if(StringUtil.isEmpty(pid)) {
continue;
}
if(robotPid!=Integer.parseInt(pid)){
continue;
}
String roomId = room_list.get(3);
if(StringUtil.isEmpty(roomId)) {
continue;
}
//判断是否有两个人
ITArray players = TArray.newFromJsonData(room_list.get(5));
if(players.size()==2) {
continue;
}
//判断另外一个用户是否是机器人
if (players.size()==1){
String otherp = String.valueOf(players.get(0));
//判断是否是机器人
Map<String,String> othermap = jedis2.hgetAll("{robot}:"+otherp);
if(othermap.size()>0){
continue;
}
}
System.out.println("roomId:"+roomId);
//加入房间
ITObject roomInfos = GroupRoomBusiness.joinRoom(robotGroupid, room, loginsession, null);
log.info("房间数据数据时数据1213234453543545------"+roomInfos);
doJoinRoom(robotid); //进入房间
ready(); //准备
setIntoRoomTime(getTime());
break;
}
}
}catch (Exception e){
}finally {
jedis11.close();
}
}
/**
@ -223,7 +377,7 @@ public class RobotUser {
Set<String> robots = jedis2.keys(robotskey);
System.out.println("robotskey:"+robotskey);
System.out.println("robots:"+robots);
if(robots.size()<2){
//if(robots.size()<2){
//创建房间
Object room = GroupRoomBusiness.matchRoom(robotGroupid, robotPid, loginsession, "Android", false);
@ -231,12 +385,14 @@ public class RobotUser {
String roomKey = String.valueOf(room);
ITObject roomInfos = GroupRoomBusiness.joinRoom(robotGroupid, roomKey, loginsession, null);
System.out.println("roomInfos:"+roomInfos);
doJoinRoom(robotid);
String roomId = roomInfos.getString("room_id");
ready();
//doJoinRoom(robotid);
this.intoRoomTime = Integer.parseInt((System.currentTimeMillis() + "").substring(0, 10));
jianting(this.client);
setStatus(ROBOTEventType.ROBOT_INTOROOM_READY);
}
//准备成功:
setIntoRoomTime( getTime());
setCurrentRoomId(Integer.parseInt(roomId));
//}
}catch (Exception e) {
log.error("joinRoomOrCreateRoom"+e.getMessage());
}finally {
@ -245,51 +401,159 @@ public class RobotUser {
}
public void jianting(TaurusClient client){
client.addEventListener(TaurusClient.NetClientEvent.OnEvent, new IEventListener() {
@Override
public void handleEvent(Event event) {
System.out.println("addList event:"+event);
}
});
client.addEventListener(TaurusClient.NetClientEvent.Connect, new IEventListener() {
@Override
public void handleEvent(Event event) {
SocketCode code = (SocketCode) event.getParameter("code");
System.out.println("code:"+code);
if (code == SocketCode.Connect) {
} else {
}
}
});
public int getTime(){
return Integer.parseInt((System.currentTimeMillis() + "").substring(0, 10));
}
/**
*
*
* @return
*/
public String doJoinRoom(int playerId) {
public Boolean doJoinRoom(int playerId) {
try {
// 添加2秒延迟
Thread.sleep(5000);
Thread.sleep(2000);
ITObject params = TObject.newInstance();
params.putString("session", loginsession + "," + token);
System.out.println("doJoinRoom:"+params);
System.out.println("dojoini:"+client.getGameID());
System.out.println("dojoini:"+client.isConnected());
client.send("1002", params, response -> {
ITObject obj = response.messageData.param.getTObject("tableInfo");
});
return "ok";
if(client.isConnected()) {
Message msg= client.send("1002", params, response -> {
System.out.println("++++++++++++++++++++++++++++=1002");
ITObject obj = response.messageData.param.getTObject("tableInfo");
ITObject reloadInfo = response.messageData.param.getTObject("reloadInfo");
if (obj!=null) {
//处理 seat
//获取机器人的seat
ITArray playerData = obj.getTArray("playerData");
for (int i = 0; i < playerData.size(); i++) {
ITObject tms = playerData.getTObject(i);
Integer tmuserid = tms.getInt("aid");
if(tmuserid==robotid){
Integer seat = tms.getInt("seat");
setSeat(seat);
}
}
System.out.println("playerData:"+playerData);
System.out.println("obj:"+obj);
System.out.println("reloadInfo:"+reloadInfo);
if(reloadInfo!=null) {
//重连回来的
int curren_outcard_seat = reloadInfo.getInt("curren_outcard_seat");
if(curren_outcard_seat==getSeat()){
//同步手牌
ITArray hand_card = reloadInfo.getTArray("hand_card");
ITArray info_list = reloadInfo.getTArray("info_list");
List<Integer> hcard = new ArrayList<>();
if(hand_card!=null) {
for (int i = 0; i < hand_card.size(); i++) {
hcard.add(hand_card.getInt(i));
}
}
ITArray outcard_list = new TArray();
if(info_list!=null) {
for (int i = 0; i < info_list.size(); i++) {
ITObject tms = info_list.getTObject(i);
Integer playerid = tms.getInt("playerid");
if(playerid==robotid){
outcard_list = tms.getTArray("outcard_list");
}
}
}
if(hcard.size()>0){
//同步手牌
huNanChangSha.updateHandCard(hcard);
if(outcard_list.size()>0){
List<Integer> outcards = new ArrayList<>();
for (int i = 0; i < outcard_list.size(); i++) {
outcards.add(outcard_list.getInt(i));
}
huNanChangSha.updateOutCard(outcards);
}
sleepTime(2000);
huNanChangSha.outCard(client,playerOutcardsMap, playerchisMap, playerpengsMap, playermingsMap, playerzisMap);
}
}
}
}
});
System.out.println("dojoinRoom:"+msg.param);
}else{
renconnect();
}
return false;
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
return false;
}
/**
* 退
*/
public void outoRoom() {
//判断当前状态是否在工作
System.out.println("outoRoom:"+ROBOTEventType.ROBOT_INTOROOM_READY);
if (getStatus() == ROBOTEventType.ROBOT_INTOROOM_READY) {
//判断房间是否有人
//room:197276
Jedis jedis0 = Redis.use("group1_db0").getJedis();
try {
System.out.println("getCurrentRoomId:"+getCurrentRoomId());
if(getCurrentRoomId()!=0){
System.out.println("getCurrentRoomId:"+ROBOTEventType.ROBOT_INTOROOM_READY);
String roomkey="room:"+getCurrentRoomId();
List<String> room_list = jedis0.hmget(roomkey, "fake", "status", "round", "id", "times", "players", "create_time", "fake_existTime");
System.out.println("room_list:"+room_list);
String roomId = room_list.get(3);
if(room_list.get(5)==null){
logoutroom();
}
ITArray players = TArray.newFromJsonData(room_list.get(5));
System.out.println("players:"+players);
if(players.size()<2){
logoutroom();
}
}
}catch (Exception e){
}finally {
jedis0.close();
}
}
}
public void logoutroom(){
ITObject params = TObject.newInstance();
params.putString("session", loginsession + "," + token);
System.out.println("logoutroom:"+params);
if(client.isConnected()){
client.send("1005", params,response -> {
});
setStatus(ROBOTEventType.ROBOT_UNUSE);
}
}
public String ready() {
try {
@ -299,17 +563,450 @@ public class RobotUser {
e.printStackTrace();
}
ITObject params = TObject.newInstance();
params.putString("session", loginsession + "," + token);
client.send("1003", params, new ICallback<MessageResponse>() {
@Override
public void action(MessageResponse messageResponse) {
System.out.println("ready");
System.out.println("params:"+params);
}
});
System.out.println("ready:"+params);
if(client.isConnected()){
client.send("1003", params, response -> {
System.out.println("1003:"+response);
});
setStatus(ROBOTEventType.ROBOT_INTOROOM_READY);
}
return null;
}
public void clientconnect(){
client.connect();
}
public void jianting(TaurusClient client){
client.addEventListener(TaurusClient.NetClientEvent.OnEvent, new IEventListener() {
@Override
public void handleEvent(Event event) {
// 获取 msg
Message message = (Message) event.getParameter("msg");
if (message == null) {
return;
}
//3005:重连
ITObject param = message.param;
//回调协议号
String command = message.command;
System.out.println("command: " + command);
System.out.println("clientId:"+client.getId());
System.out.println("message:"+client.getSession());
//根据玩法id 调用不同的回调
if (StringUtil.isNotEmpty(command)) {
System.out.println("command: "+robotid+"--------------" + command);
//长沙麻将 机器人处理事件
if ("811".equalsIgnoreCase(command)) {
setStatus(ROBOTEventType.ROBOT_INTOROOM_WORKING);
//初始化收手牌
// System.out.println("初始化手牌" + session);
Jedis jedis222 = Redis.use("group1_db2").getJedis();
String key = robotid+"";
log.info("key+++++++++++++++++++++++++++++++++++" + key);
if (jedis222.hget("{robortInfo}:" + key, "circleId") != null && jedis222.hget("{robortInfo}:" + key, "pid") != null) {
String circleId = jedis222.hget("{robortInfo}:" + key, "circleId");
log.info("circleId +++++++++++++++++++++++++"+circleId);
String pid = jedis222.hget("{robortInfo}:" + key, "pid");
log.info("pid +++++++++++++++++++++++++"+pid);
String getStart = "g{" + circleId + "}:play:" + pid;
if (!pid.equals("0")){
log.info("getStart +++++++++++++++++++++++++"+getStart);
jedis222.hset(getStart, key, "2");
}
}
jedis222.close();
huNanChangSha.cardInHead(command, message, client);
log.info("client " + client);
} else if ("812".equalsIgnoreCase(command)) {//出牌广播
//{"opzicards":[{"opzicards":[],"playerId":101555}],"opmingcards":[{"opmingcards":[],"playerId":101555}],"outcard_map":[{"outcards":[209,205],"playerId":101555},{"outcards":[],"playerId":112233}],"card":205,"opchicards":[{"opchicards":[105,103],"playerId":101555}],"oppengcards":[{"oppengcards":[],"playerId":101555}],"seat":1}
ITArray outcard_map = param.getTArray("outcard_map");
ITArray opchicards = param.getTArray("opchicards");
ITArray oppengcards = param.getTArray("oppengcards");
ITArray opmingcards = param.getTArray("opmingcards");
ITArray opzicards = param.getTArray("opzicards");
// 清空旧数据,用新数据完全覆盖
playerOutcardsMap.clear();
playerchisMap.clear();
playerpengsMap.clear();
playermingsMap.clear();
playerzisMap.clear();
//出过的牌
if (outcard_map != null) {
for (int i = 0; i < outcard_map.size(); i++) {
ITObject playerData = outcard_map.getTObject(i);
int playerId = playerData.getInt("playerId");
ITArray outcardsArray = playerData.getTArray("outcards");
// 转换为List<Integer>
List<Integer> outcardsList = new ArrayList<>();
for (int j = 0; j < outcardsArray.size(); j++) {
outcardsList.add(outcardsArray.getInt(j));
}
// 存储到Map中覆盖旧数据
playerOutcardsMap.put(playerId, outcardsList);
}
}
//吃的牌
if (opchicards != null) {
for (int i = 0; i < opchicards.size(); i++) {
ITObject playerData = opchicards.getTObject(i);
int playerId = playerData.getInt("playerId");
ITArray outchiArray = playerData.getTArray("opchicards");
List<Integer> outchiList = new ArrayList<>();
for (int j = 0; j < outchiArray.size(); j++) {
outchiList.add(outchiArray.getInt(j));
}
playerchisMap.put(playerId, outchiList);
}
}
//碰的牌
if (oppengcards != null) {
for (int i = 0; i < oppengcards.size(); i++) {
ITObject playerData = oppengcards.getTObject(i);
int playerId = playerData.getInt("playerId");
ITArray outpengArray = playerData.getTArray("oppengcards");
List<Integer> outpengList = new ArrayList<>();
for (int j = 0; j < outpengArray.size(); j++) {
outpengList.add(outpengArray.getInt(j));
}
playerpengsMap.put(playerId, outpengList);
}
}
//明杠的牌
if (opmingcards != null) {
for (int i = 0; i < opmingcards.size(); i++) {
ITObject playerData = opmingcards.getTObject(i);
int playerId = playerData.getInt("playerId");
ITArray outmingArray = playerData.getTArray("opmingcards");
List<Integer> outmingList = new ArrayList<>();
for (int j = 0; j < outmingArray.size(); j++) {
outmingList.add(outmingArray.getInt(j));
}
playermingsMap.put(playerId, outmingList);
}
}
//暗杠的牌
if (opzicards != null) {
for (int i = 0; i < opzicards.size(); i++) {
ITObject playerData = opzicards.getTObject(i);
int playerId = playerData.getInt("playerId");
ITArray outziArray = playerData.getTArray("opzicards");
List<Integer> outziList = new ArrayList<>();
for (int j = 0; j < outziArray.size(); j++) {
outziList.add(outziArray.getInt(j));
}
playerzisMap.put(playerId, outziList);
}
}
HuNanChangSha.drawCard(command, message);
} else if ("819".equalsIgnoreCase(command)) {
huNanChangSha.getCard(command, message, client);
} else if ("813".equalsIgnoreCase(command)) {//出牌提示
System.out.println("进入出牌11111111111111112222222");
System.out.println("client4444444444444444" + client);
huNanChangSha.outCard(client, playerOutcardsMap, playerchisMap, playerpengsMap, playermingsMap, playerzisMap);
} else if ("814".equalsIgnoreCase(command)) {
//吃碰杠
huNanChangSha.actionCard(param, client);
}else if("2002".equalsIgnoreCase(command)) {
System.out.println("comds:2002");
ITObject params = TObject.newInstance();
String aid = client.getGameID();
String getKey = "{robortInfo}:" + aid;
Jedis jedis20 = Redis.use("group1_db2").getJedis();
String circleId1 = jedis20.hget(getKey, "circleId");
String pid = jedis20.hget(getKey, "pid");
String key = "g{" + circleId1 + "}:play:" + pid;
client.send("1005", params, response -> {
log.info("退出状态1---------"+response);
log.info("退出状态1getKey---------"+getKey);
log.info("退出状态1key---------"+key);
log.info("退出状态1aid---------"+aid);
jedis20.hset(getKey, "circleId", "0");
jedis20.hset(getKey, "pid", "0");
jedis20.hset(getKey, "room_id", "0");
//退出修改机器人状态
jedis20.hset(key,aid, "0");
});
jedis20.close();
}else if ("2009".equalsIgnoreCase(command)) {
log.info("斤斤计较急急急急急急急急急====="+param);
// sleepTime(3000);
//db0
Jedis jedis22 = Redis.use().getJedis();
//db2
Jedis jedis33 = Redis.use("group1_db2").getJedis();
Jedis jedis = Redis.use("group1_db0").getJedis();
String aid = client.getGameID();
String getKey = "{robortInfo}:" + aid;
log.info("连接的id---------------:"+aid);
ITObject params = TObject.newInstance();
String[] playerIds2 = null;
if (jedis33.hget(getKey, "pid") != null) {
String circleId1 = jedis33.hget(getKey, "circleId");
String pid = jedis33.hget(getKey, "pid");
String key = "g{" + circleId1 + "}:play:" + pid;
if (jedis33.hget(getKey, "room_id") != null) {
String roomid = jedis33.hget(getKey, "room_id");
String roomKey = "room:" + roomid;
Integer start = param.getInt("start");
log.info("获取数据的key----------------"+ key);
if (start == 1){
log.info("进入修好状态12345------------"+aid);
jedis33.hset(key, aid, "2");
log.info("进入修好状态ttttttttttttttt------------"+jedis33.hget(key, aid));
}
if (jedis22.hget(roomKey, "players") != null) {
String players = jedis22.hget(roomKey, "players");
if (!players.equals("[]")) {
players = players.substring(1, players.length() - 1);
playerIds2 = players.split(",");
if (playerIds2.length == 1) {
if (!pid.equals("0")) {
Jedis jedis20 = Redis.use("group1_db11").getJedis();
System.out.println("进入 -------------------------");
jedis20.hincrBy(key, "leftover_robot", 1);
jedis20.close();
// 获取指定field的值
String value = jedis33.hget(key, aid);
log.info("2009-----value----"+ value);
if (!value.equals("2")) {
// log.info("jiqiren.count333333333333333333333333-------------"+jiqiren.count2);
if (jiqiren.count2 != null && jiqiren.count2.containsKey(Integer.parseInt(pid))) {
Integer currentValue = jiqiren.count2.get(Integer.parseInt(pid));
if (currentValue > 0) {
jiqiren.count2.put(Integer.parseInt(pid), currentValue - 1);
}
}
System.out.println("jiqiren.count2000000000000-------------"+jiqiren.count2);
if (jiqiren.count2 != null && jiqiren.count2.containsKey(Integer.parseInt(pid))) {
Integer value1 = jiqiren.count2.get(Integer.parseInt(pid));
// 如果找到了对应的 pid
Jedis jedis12 = Redis.use("group1_db11").getJedis();
String shangxianRobot = jedis12.hget(key, "shangxian_robot");
String leftoverRobot = jedis12.hget(key, "leftover_robot");
if (shangxianRobot != null && leftoverRobot != null) {
if (value1 == 0) {
System.out.println("key leftover_robot " + key);
jedis12.hset(key, "leftover_robot", shangxianRobot);
}
}
jedis12.close();
}
sleepTime(5000);
String valueq = jedis33.hget(key, aid);
log.info("redis----状态状态111223243546----"+ valueq);
if (!valueq.equals("2")){
client.send("1005", params, response -> {
log.info("退出状态---------"+response);
log.info("退出状态getKey---------"+getKey);
log.info("退出状态key---------"+key);
log.info("退出状态aid---------"+aid);
jedis33.hset(getKey, "circleId", "0");
jedis33.hset(getKey, "pid", "0");
jedis33.hset(getKey, "room_id", "0");
//退出修改机器人状态
jedis33.hset(key,aid, "0");
});
}
}
}
}
}
}
}
jedis33.close();
jedis22.close();
jedis.close();
}
} else if ("2001".equalsIgnoreCase(command)){
log.info("2001-------状态状态------"+param);
}else if ("817".equalsIgnoreCase(command)) {//结算
huNanChangSha.getChangShaCardInhand().clear();
huNanChangSha.getChuGuoCardInhand().clear();
huNanChangSha.getpongGroup().clear();
huNanChangSha.getchowGroup().clear();
TinHuChi.lastTingCount = 0;
TinHuChi.isMoreThanLast = false;
ChangShaSuanFaTest.isTin = false;
ChangShaSuanFaTest.isChi = false;
ChangShaSuanFaTest.isPeng = false;
ChangShaSuanFaTest.tinCards.clear();
Integer type = param.getInt("type");
if (type == 1 || type == 2) { //为1为大结算 为2为解散
Jedis jedis11s = Redis.use("group1_db11").getJedis();
try {
//db2
Jedis jedis21 = Redis.use("group1_db2").getJedis();
try {
String key = robotid+"";
if (jedis21.hget("{robortInfo}:" + key, "circleId") != null && jedis21.hget("{robortInfo}:" + key, "pid") != null) {
String circleId = jedis21.hget("{robortInfo}:" + key, "circleId");
String pid = jedis21.hget("{robortInfo}:" + key, "pid");
String getStart = "g{" + circleId + "}:play:" + pid;
jedis21.hset(getStart, key, "0");
System.out.println("jiqiren.count2886746435243211-------------"+jiqiren.count2);
if (jiqiren.count2 != null && jiqiren.count2.containsKey(Integer.parseInt(pid))) {
Integer currentValue = jiqiren.count2.get(Integer.parseInt(pid));
if (currentValue > 0) {
jiqiren.count2.put(Integer.parseInt(pid), currentValue - 1);
}
}
// jedis11s.hincrBy(getStart, "leftover_robot", 1);
jedis21.hset("{robortInfo}:" + key, "circleId", "0");
jedis21.hset("{robortInfo}:" + key, "pid", "0");
jedis21.hset("{robortInfo}:" + key, "room_id", "0");
System.out.println("jiqiren.count2-------------"+jiqiren.count2);
if (jiqiren.count2 != null && jiqiren.count2.containsKey(Integer.parseInt(pid))) {
Integer value = jiqiren.count2.get(Integer.parseInt(pid));
// 如果找到了对应的 pid
Jedis jedis12 = Redis.use("group1_db11").getJedis();
String shangxianRobot = jedis12.hget(key, "shangxian_robot");
String leftoverRobot = jedis12.hget(key, "leftover_robot");
if (shangxianRobot != null && leftoverRobot != null) {
if (value == 0) {
jedis12.hset(key, "leftover_robot", shangxianRobot);
}
}
jedis12.close();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
jedis21.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
jedis11s.close();
}
}
ready();
//写定时器
} else if ("815".equalsIgnoreCase(command)) { //服务器通知客户端有玩家执行了操作
//[TCP->815] data:{"playerid":101555,"card":104,"opcard":[105,103],"from_seat":2,"type":1,"opengang":false}
huNanChangSha.shanchuchuguopai(param);
} else if ("820".equalsIgnoreCase(command)) {//换牌提示
huNanChangSha.changePlayer(command, message);
} else if ("2008".equalsIgnoreCase(command)) { //解散房间时候恢复机器人账号可以使用
setStatus(ROBOTEventType.ROBOT_UNUSE);
} else if ("825".equalsIgnoreCase(command)) {
ITObject params = TObject.newInstance();
params.putInt("qi", 0);
params.putInt("id", 1);
client.send("612", params, response -> {
});
} else if ("822".equalsIgnoreCase(command)) {
ITObject params = TObject.newInstance();
//params.putInt("qi", 0);
params.putInt("id", 1);
//[TCP->822] data:{"tip_list":[{"type":8,"id":1,"opcard":[],"weight":8,"card":0}],"types":[{"type":21,"value":1}]}
//板胡Event [TCP->823] data:{"type":8,"seat":1,"data":[{"opcard":[204,204,204,108,108,108],"type":21,"value":1}]}
client.send("612", params, response -> {
});
} else if ("835".equalsIgnoreCase(command)) { //听牌天听
ITObject params = TObject.newInstance();
params.putInt("qi", 0);
params.putInt("id", 1);
client.send("612", params, response -> {
});
}
//END 长沙麻将
}
}
});
client.addEventListener(TaurusClient.NetClientEvent.Connect, new IEventListener() {
@Override
public void handleEvent(Event event) {
SocketCode code = (SocketCode) event.getParameter("code");
if (code == SocketCode.Disconnect) {
client.connect();
} else {
}
}
});
}
public static void sleepTime(int time) {
try {
// 添加延迟
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

View File

@ -65,6 +65,9 @@ public class Paixing {
return false;
}
if(drawCard == 0)return true;
if(cardInhand.size() == 0) {
return false;
}
if (cardInhand.get(0) != drawCard)
return false;
return true;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More