Skip to main content
9 of 12
saved 2 bytes
Arnauld
  • 197.8k
  • 20
  • 180
  • 650

#JavaScript (ES7),  216 ... 205 201  199 bytes

Takes input as (block)(double), where block is either \$-2\$ (top right), \$-1\$ (bottom left), \$1\$ (bottom right) or \$2\$ (top left) and double is a Boolean value.

b=>d=>(g=x=>y<31?`+-| =OTF
`[X=x-19,Y=y-15,p=X*Y*b<0,q=Y>0^b&1,X*=X,Y*=Y,i=x*24%35>2|~16>>Y%62%6&2,x<39?Y?p*X|(d?Y:X-87)>169?3:i?X-1|Y-16|q?i:7:q*(d?X-87:Y)%169&&6:x%38?4:5:++y&&8]+g(-~x%40):'')(y=0)

Try it online!

Formatted version

###How?

We iterate from \$y=0\$ to \$y=30\$ and from from \$x=0\$ to \$x=39\$ for each value of \$y\$.

We first define \$X=x-19\$ and \$Y=y-15\$.

The variables p = X * Y * b < 0 and q = Y > 0 ^ b & 1 are used to determine what do draw in each quarter according to the block \$b\$.

From now on, both \$X\$ and \$Y\$ are squared in order to easily test absolution positions within each quarter of the field.

The expression x * 24 % 35 > 2 yields false if \$x\$ belongs to \$\{0, 3, 19, 35, 38\}\$ (the positions of the vertical lines) or true otherwise.

Try it online!

The expression ~16 >> Y % 62 % 6 & 2 yields \$0\$ if \$y\$ belongs to \$\{0, 2, 12, 18, 28, 30\}\$ (the positions of the horizontal lines, excluding the net) or \$2\$ otherwise.

Try it online!

The variable \$i\$ is defined as the result of a bitwise OR between the two values above, and is therefore interpreted as:

  • 3: space
  • 2: |
  • 1: -
  • 0: + or T

The expression (d ? Y : X - 87) > 169 is used to crop the field according to the game type \$d\$ (single or double). The similar expression (d ? X - 87 : Y) % 169 is used to draw the T's at the appropriate positions.

Arnauld
  • 197.8k
  • 20
  • 180
  • 650