001package ball.game.chess; 002/*- 003 * ########################################################################## 004 * Game Applications and Utilities 005 * $Id: Piece.java 5832 2020-04-19 18:22:39Z ball $ 006 * $HeadURL: svn+ssh://svn.hcf.dev/var/spool/scm/repository.svn/ball-game/trunk/src/main/java/ball/game/chess/Piece.java $ 007 * %% 008 * Copyright (C) 2010 - 2020 Allen D. Ball 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * ########################################################################## 022 */ 023import lombok.Data; 024import lombok.NonNull; 025 026/** 027 * Chess {@link Piece}. 028 * 029 * {@bean.info} 030 * 031 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball} 032 * @version $Revision: 5832 $ 033 */ 034@Data 035public class Piece { 036 private static final String[][] UNICODE = { 037 /* White, Black */ 038 /* K */ { "\u2654", "\u265a" }, 039 /* Q */ { "\u2655", "\u265b" }, 040 /* R */ { "\u2656", "\u265c" }, 041 /* B */ { "\u2657", "\u265d" }, 042 /* N */ { "\u2658", "\u265e" }, 043 /* P */ { "\u2659", "\u265f" } 044 }; 045 046 @NonNull private final Rank rank; 047 @NonNull private final Color color; 048 049 @Override 050 public String toString() { 051 return UNICODE[rank.ordinal()][color.ordinal()]; 052 } 053 054 /** 055 * {@link Piece} {@link Rank}. 056 */ 057 public enum Rank { K, Q, R, B, N, P; } 058}