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