Exemplo n.º 1
0
 /**
  * Render Meta Box content.
  *
  * @param WP_Post $post The post object.
  */
 public function render_character_meta_box_content($post)
 {
     //n = name, sp = species, a = alignment, g = gender, b = behaviour, sk = skill, st = stamina, l = luck, gd = gold;
     // Add an nonce field so we can check for it later.
     wp_nonce_field('wpifw_inner_custom_box', 'wpifw_inner_custom_box_nonce');
     // Use get_post_meta to retrieve an existing value from the database.
     $show_the_value = get_post_meta($post->ID, '_character_profile', true);
     if (!$show_the_value) {
         $newCharacter = 1;
         $key = array();
     }
     $key = get_the_title($ID);
     if ($key == '') {
         $show_the_value = array();
         $key = array();
     }
     // Display the form, using the current value.
     echo '<table class="form-table">';
     echo '<tbody>';
     $allow_classes = get_option('allow_classes');
     $count_classes = wp_count_posts('character_defaults');
     if ($allow_classes == 'on' && $count_classes->publish > 0) {
         echo '<tr scope="row">';
         echo '<th>';
         echo '<label for="wpifw_parentClass">';
         _e('Use Class', 'wpifw_text');
         echo '</label> ';
         echo '</th>';
         echo '<td>';
         $useClass = $show_the_value[$key]['useClass'];
         echo '<input type="checkbox" id="wpifw_use_class_yes" name="wpifw_use_class_yes"';
         if ($useClass == 'on') {
             echo ' checked ';
         }
         echo '>Yes</input>';
         echo '</td>';
         echo '</tr>';
         echo '<tr scope="row" id="classRow"';
         if ($useClass != 'on') {
             echo ' style="display:none" ';
         }
         echo '>';
         $characterClass = $show_the_value[$key]['species'];
         echo '<th>';
         echo '<label for="wpifw_parentClass">';
         _e('Character Class', 'wpifw_text');
         echo '</label> ';
         echo '</th>';
         echo '<td>';
         echo '<select type="dropdown" id="wpifw_character_species" name="wpifw_character_species">';
         echo wpifw_utils::wpifw_generate_class_options($characterClass);
         echo '</select> ';
         echo '</td>';
         echo '</tr>';
     }
     echo '<tr scope="row">';
     $characterAlignment = $show_the_value[$key]['alignment'];
     echo '<th>';
     echo '<label for="wpifw_character_alignment">';
     _e('Alignment', 'wpifw_text');
     echo '</label> ';
     echo '</th>';
     echo '<td>';
     echo '<select type="dropdown" id="wpifw_character_alignment" name="wpifw_character_alignment">';
     echo '<option value="Friend" ';
     if ($characterAlignment == 'Friend') {
         echo 'selected';
     }
     echo ' >';
     _e('Friend', 'wpifw_text');
     echo '</option>';
     echo '<option value="Foe" ';
     if ($characterAlignment == 'Foe') {
         echo 'selected';
     }
     echo ' >';
     _e('Foe', 'wpifw_text');
     echo '</option>';
     echo '<option value="Neutral" ';
     if ($characterAlignment == 'Neutral') {
         echo 'selected';
     }
     echo ' >';
     _e('Neutral', 'wpifw_text');
     echo '</option>';
     echo '</select> ';
     echo '</td>';
     echo '</tr>';
     echo '<tr scope="row">';
     $characterGender = $show_the_value[$key]['gender'];
     echo '<th>';
     echo '<label for="wpifw_character_gender">';
     _e('Gender', 'wpifw_text');
     echo '</label> ';
     echo '</th>';
     echo '<td>';
     echo '<select type="dropdown" id="wpifw_character_gender" name="wpifw_character_gender">';
     echo '<option value="Male" ';
     if ($characterGender == 'Male') {
         echo 'selected';
     }
     echo ' >';
     _e('Male', 'wpifw_text');
     echo '</option>';
     echo '<option value="Female" ';
     if ($characterGender == 'Female') {
         echo 'selected';
     }
     echo ' >';
     _e('Female', 'wpifw_text');
     echo '</option>';
     echo '<option value="It" ';
     if ($characterGender == 'It') {
         echo 'selected';
     }
     echo ' >';
     _e('It', 'wpifw_text');
     echo '</option>';
     echo '</select> ';
     echo '</td>';
     echo '</tr>';
     echo '<tr scope="row">';
     $characterBehaviour = $show_the_value[$key]['behaviour'];
     echo '<th>';
     echo '<label for="wpifw_character_behaviour">';
     _e('Behaviour', 'wpifw_text');
     echo '</label> ';
     echo '</th>';
     echo '<td>';
     echo '<select type="dropdown" id="wpifw_character_behaviour" name="wpifw_character_behaviour">';
     echo '<option value="Attacker" ';
     if ($characterBehaviour == 'Attacker') {
         echo 'selected';
     }
     echo ' >';
     _e('Attacker', 'wpifw_text');
     echo '</option>';
     echo '<option value="Defender" ';
     if ($characterBehaviour == 'Defender') {
         echo 'selected';
     }
     echo ' >';
     _e('Defender', 'wpifw_text');
     echo '</option>';
     echo '</select> ';
     echo '</td>';
     echo '</tr>';
     //begin stats
     $useDefaults = $show_the_value[$key]['useDefaults'];
     if ($allow_classes == 'on' && $count_classes->publish > 0) {
         echo '<tr scope="row">';
         echo '<th colspan="2">';
         echo '<hr />';
         echo '</th>';
         echo '</tr>';
         if ($useClass === 'on') {
             echo '<tr scope="row" id="use_stat_defaults" style="display:table-row">';
         } else {
             echo '<tr scope="row" id="use_stat_defaults" style="display:none">';
         }
         echo '<th>';
         echo '<label for="wpifw_character_use">';
         _e('Use Class defaults?', 'wpifw_text');
         echo '</label> ';
         echo '</th>';
         echo '<td>';
         echo '<input type="checkbox" id="wpifw_use_defaults_yes" name="wpifw_use_defaults_yes"';
         if ($useDefaults === 'on') {
             echo ' checked';
         }
         echo '></input> Yes ';
         echo '</td>';
         echo '</tr>';
         echo '</tbody>';
         echo '</table>';
     }
     echo '<table class="form-table" id="character-stats">';
     //Skill
     echo '<tbody>';
     echo '<tr scope="row">';
     echo '<th>';
     echo '<label for="wpifw_character_skill">';
     _e('Skill', 'wpifw_text');
     echo '</label> ';
     echo '</th>';
     echo '<td>';
     if (!$newCharacter) {
         $skillroll = $show_the_value[$key]['skill'][0];
     } else {
         $skillroll = "2d6";
     }
     echo '<select type="dropdown" id="wpifw_skill_d1" name="wpifw_skill_d1">';
     echo wpifw_utils::wpifw_generate_dice_options('quantity', $skillroll);
     echo '</select>';
     echo ' x ';
     echo '<select type="dropdown" id="wpifw_skill_d2" name="wpifw_skill_d2">';
     echo wpifw_utils::wpifw_generate_dice_options('type', $skillroll);
     echo '</select>';
     echo ' Sided Dice ';
     echo '</td>';
     echo '</tr>';
     //stamina
     echo '<tr scope="row">';
     echo '<th>';
     echo '<label for="wpifw_character_stamina">';
     _e('Stamina', 'wpifw_text');
     echo '</label> ';
     echo '</th>';
     echo '<td>';
     if (!$newCharacter) {
         $staminaroll = $show_the_value[$key]['stamina'][0];
     } else {
         $staminaroll = "2d6";
     }
     echo '<select type="dropdown" id="wpifw_stamina_d1" name="wpifw_stamina_d1">';
     echo wpifw_utils::wpifw_generate_dice_options('quantity', $staminaroll);
     echo '</select>';
     echo ' x ';
     echo '<select type="dropdown" id="wpifw_stamina_d2" name="wpifw_stamina_d2">';
     echo wpifw_utils::wpifw_generate_dice_options('type', $staminaroll);
     echo '</select>';
     echo ' Sided Dice ';
     echo '</td>';
     echo '</tr>';
     //Luck
     echo '<tr scope="row">';
     echo '<th>';
     echo '<label for="wpifw_character_luck">';
     _e('Luck', 'wpifw_text');
     echo '</label> ';
     echo '</th>';
     echo '<td>';
     if (!$newCharacter) {
         $luckroll = $show_the_value[$key]['luck'][0];
     } else {
         $luckroll = "2d6";
     }
     echo '<select type="dropdown" id="wpifw_luck_d1" name="wpifw_luck_d1">';
     echo wpifw_utils::wpifw_generate_dice_options('quantity', $luckroll);
     echo '</select>';
     echo ' x ';
     echo '<select type="dropdown" id="wpifw_luck_d2" name="wpifw_luck_d2">';
     echo wpifw_utils::wpifw_generate_dice_options('type', $luckroll);
     echo '</select>';
     echo ' Sided Dice ';
     echo '</td>';
     echo '</tr>';
     //Gold
     echo '<tr scope="row">';
     if (!$newCharacter) {
         $goldroll = $show_the_value[$key]['gold'][0];
     } else {
         $goldroll = "2d6";
     }
     echo '<th>';
     echo '<label for="wpifw_gold">';
     _e('Currency', 'wpifw_text');
     echo '</label> ';
     echo '</th>';
     echo '<td>';
     echo '<input type="checkbox" id="wpifw_has_gold" name="wpifw_has_gold" value="has_gold" ';
     if ($goldroll != 0) {
         echo ' checked';
     }
     echo '/> ';
     _e('Can Have Currency', 'wpifw_text');
     echo '<br />';
     echo '<div id="gold_selector" style="display:';
     if ($goldroll != 0) {
         echo 'block">';
     } else {
         echo 'none">';
     }
     echo '<br /><select type="dropdown" id="wpifw_gold_d1" name="wpifw_gold_d1">';
     echo wpifw_utils::wpifw_generate_dice_options('quantity', $goldroll);
     echo '</select>';
     echo ' x ';
     echo '<select type="dropdown" id="wpifw_gold_d2" name="wpifw_gold_d2">';
     echo wpifw_utils::wpifw_generate_dice_options('type', $goldroll);
     echo '</select>';
     echo ' Sided Dice ';
     echo '</div>';
     echo '</td>';
     echo '</tr>';
     //end stats
     echo '</tbody>';
     echo '</table>';
 }
    echo '<label for="wpifw_defeat">';
    _e('If defeated, go to: ', 'wpifw_text');
    ?>
</label></th> 
                        		<?php 
    $defeat = $show_the_value[2]['defeat'];
    ?>
                                <td><select type="dropdown" name="defeat" id="destination-dropdown"><?php 
    wpifw_utils::wpifw_get_scenes_in_act($defeat);
    ?>
</select></td>
							</tr>
						</tbody> 
					</table>    	
					<div style="display:none"><select type="dropdown" name="combatants[]" class="randomClass"><option>Select...</option><?php 
    wpifw_utils::wpifw_generate_class_options();
    ?>
</select></div>
				<?php 
    echo '</div>';
}
/*
 * Display the LUCK options
 *
 */
if ($allow_luck == 'on') {
    echo '<div id="luck-options" style="display:';
    if ($follow_on_type == 'luck-options') {
        echo 'block">';
    } else {
        echo 'none">';