mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Crude initial version of ASCII representation for blind players.
This commit is contained in:
parent
972c3d0d6f
commit
8ab6f36364
4 changed files with 59 additions and 4 deletions
|
@ -7,6 +7,7 @@ FlagLank = require 'lib/surface/FlagLank'
|
|||
Lank = require 'lib/surface/Lank'
|
||||
Mark = require './Mark'
|
||||
Grid = require 'lib/world/Grid'
|
||||
utils = require 'core/utils'
|
||||
|
||||
module.exports = class LankBoss extends CocoClass
|
||||
subscriptions:
|
||||
|
@ -213,6 +214,24 @@ module.exports = class LankBoss extends CocoClass
|
|||
if @willSelectThang and @lanks[@willSelectThang[0]]
|
||||
@selectThang @willSelectThang...
|
||||
|
||||
@updateScreenReader()
|
||||
|
||||
updateScreenReader: ->
|
||||
# Testing ASCII map for screen readers
|
||||
return unless me.get('name') is 'zersiax' #in ['zersiax', 'Nick']
|
||||
ascii = $('#ascii-surface')
|
||||
thangs = (lank.thang for lank in @lankArray)
|
||||
grid = new Grid thangs, @world.width, @world.height, 0, 0, 0, true
|
||||
utils.replaceText ascii, grid.toString true
|
||||
ascii.css 'transform', 'initial'
|
||||
fullWidth = ascii.innerWidth()
|
||||
fullHeight = ascii.innerHeight()
|
||||
availableWidth = ascii.parent().innerWidth()
|
||||
availableHeight = ascii.parent().innerHeight()
|
||||
scale = availableWidth / fullWidth
|
||||
scale = Math.min scale, availableHeight / fullHeight
|
||||
ascii.css 'transform', "scale(#{scale})"
|
||||
|
||||
equipNewItems: (thang) ->
|
||||
itemsJustEquipped = []
|
||||
if thang.equip and not thang.equipped
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# TODO: this thing needs a bit of thinking/testing for grid square alignments, exclusive vs. inclusive mins/maxes, etc.
|
||||
|
||||
module.exports = class Grid
|
||||
constructor: (thangs, @width, @height, @padding=0, @left=0, @bottom=0) ->
|
||||
constructor: (thangs, @width, @height, @padding=0, @left=0, @bottom=0, @rogue=false) ->
|
||||
@width = Math.ceil @width
|
||||
@height = Math.ceil @height
|
||||
@left = Math.floor @left
|
||||
|
@ -14,7 +14,11 @@ module.exports = class Grid
|
|||
@grid.push []
|
||||
for x in [0 .. @width]
|
||||
@grid[y].push []
|
||||
for thang in thangs when thang.collides
|
||||
if @rogue
|
||||
thangs = (t for t in thangs when t.collides or t.spriteName is 'Gem' and not t.dead)
|
||||
else
|
||||
thangs = (t for t in thangs when t.collides)
|
||||
for thang in thangs
|
||||
rect = thang.rectangle()
|
||||
[minX, maxX, minY, maxY] = [9001, -9001, 9001, -9001]
|
||||
for v in rect.vertices()
|
||||
|
@ -48,7 +52,24 @@ module.exports = class Grid
|
|||
rows: (minX, maxX) ->
|
||||
[@clampRow(minX) ... @clampRow(maxX)]
|
||||
|
||||
toString: ->
|
||||
toString: (rogue=false) ->
|
||||
upsideDown = _.clone @grid
|
||||
upsideDown.reverse()
|
||||
(((if thangs.length then ('' + thangs.length) else ' ') for thangs in row).join(' ') for row in upsideDown).join("\n")
|
||||
((@charForThangs thangs, rogue for thangs in row).join(' ') for row in upsideDown).join("\n")
|
||||
|
||||
charForThangs: (thangs, rogue) ->
|
||||
return thangs.length or ' ' unless rogue
|
||||
return '.' unless thangs.length
|
||||
return '@' if _.find thangs, (t) -> /Hero Placeholder/.test t.id
|
||||
return '>' if _.find thangs, spriteName: 'Spike Walls'
|
||||
return 'F' if _.find thangs, spriteName: 'Fence Wall'
|
||||
return 'T' if _.find thangs, spriteName: 'Fire Trap'
|
||||
return ' ' if _.find thangs, spriteName: 'Dungeon Wall'
|
||||
return 'G' if _.find thangs, spriteName: 'Gem'
|
||||
return 'C' if _.find thangs, spriteName: 'Treasure Chest'
|
||||
return '*' if _.find thangs, spriteName: 'Spear'
|
||||
return 'o' if _.find thangs, type: 'munchkin'
|
||||
return 'O' if _.find thangs, (t) -> t.team is 'ogres'
|
||||
return 'H' if _.find thangs, (t) -> t.team is 'humans'
|
||||
return 'N' if _.find thangs, (t) -> t.team is 'neutral'
|
||||
return '?'
|
||||
|
|
|
@ -101,6 +101,19 @@ $level-resize-transition-time: 0.5s
|
|||
&.flag-color-selected
|
||||
cursor: crosshair
|
||||
|
||||
#ascii-surface
|
||||
position: absolute
|
||||
z-index: 3
|
||||
top: 0
|
||||
left: 0
|
||||
pointer-events: none
|
||||
white-space: pre
|
||||
font-family: Courier, monospace
|
||||
color: white
|
||||
background-color: rgba(14, 59, 130, 0.25)
|
||||
transform-origin: 0 0 0
|
||||
line-height: 15px
|
||||
|
||||
min-width: 1024px
|
||||
position: relative
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#canvas-wrapper
|
||||
canvas(width=924, height=589)#webgl-surface
|
||||
canvas(width=924, height=589)#normal-surface
|
||||
#ascii-surface
|
||||
#canvas-left-gradient.gradient
|
||||
#canvas-top-gradient.gradient
|
||||
#goals-view
|
||||
|
@ -41,3 +42,4 @@ if !me.get('anonymous')
|
|||
#play-footer(class=me.isPremium() ? "premium" : "")
|
||||
p(class='footer-link-text')
|
||||
a.contact-link(title='Send CodeCombat a message', tabindex=-1, data-i18n="nav.contact") Contact
|
||||
|
||||
|
|
Loading…
Reference in a new issue